myinfo.aspx.cs

来自「一个简单的网上书店」· CS 代码 · 共 66 行

CS
66
字号
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Model;
using BLL;
using BLL.interfaces;
using System.Collections.Generic;

public partial class myinfo : System.Web.UI.Page
{

    IUsers userMessage = Factory.greatUsers();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["userId"] == null)
                Response.Redirect("login.aspx");
            int i = int.Parse(Session["userId"].ToString().Trim());
            ViewState["userId"] =i ;
            show();
        }
    }
    private void show() 
    {
        List<Users> list = new List<Users>();
        list = userMessage.selOnly((int)ViewState["userId"]);
        if (list != null)
        {
            dlvmyinfo.DataSource = list;
            dlvmyinfo.DataBind();
        }
        else 
        {
            Response.Redirect("error.aspx");
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        TextBox txtaddress=  dlvmyinfo.FindControl("txtaddress") as TextBox;
        TextBox txtphone = dlvmyinfo.FindControl("txtphone") as TextBox;
        string address = txtaddress.Text;
        string phone = txtphone.Text;
        Users user=new Users();
        user.Address=address;
        user.Phone=phone;
        user.Id=(int)ViewState["userId"];
        if (userMessage.updateMy(user))
        {
            Response.Write("<script>alert('服务器已经接受您的请求!')</script>");
        }
        else 
        {
            Response.Redirect("error.aspx");
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?