Example #1
0
    protected void lvUserList_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
    {
        Label lblnID = (Label)lvUserList.Items[e.NewSelectedIndex].FindControl("lblnUserID");
        int   _nID   = 0;

        DBLL.clsUser user = new DBLL.clsUser();
        if (int.TryParse(lblnID.Text.Trim(), out _nID) && _nID > 0)
        {
            MultiView1.ActiveViewIndex = 1;
            DataTable dt = user.Select_tb_UserBynUserID(_nID);
            txtsUsername.Text = dt.Rows[0]["sUsername"].ToString();
            txtsPassword.Text = dt.Rows[0]["sPassword"].ToString();
            txtsPassword.Attributes.Add("Value", txtsPassword.Text);
            txtsPassword2.Text = dt.Rows[0]["sPassword"].ToString();
            txtsPassword2.Attributes.Add("Value", txtsPassword2.Text);
            txtsRealName.Text          = dt.Rows[0]["sRealName"].ToString();
            rblnUserSex.SelectedValue  = dt.Rows[0]["nUserSex"].ToString();
            txtsUserQQ.Text            = dt.Rows[0]["sUserQQ"].ToString();
            txtsUserMSN.Text           = dt.Rows[0]["sUserMSN"].ToString();
            txtsUserPhone.Text         = dt.Rows[0]["sUserPhone"].ToString();
            txtsUserEmail.Text         = dt.Rows[0]["sUserEmail"].ToString();
            cbIsContact.Checked        = bool.Parse(dt.Rows[0]["IsContact"].ToString());
            cbIsInquiry.Checked        = bool.Parse(dt.Rows[0]["IsInquiry"].ToString());
            rblnUserType.SelectedValue = dt.Rows[0]["nUserType"].ToString();
            hfUserUpdateID.Value       = _nID.ToString();
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int nID = 0;
         if (Request.QueryString["nID"] != null && int.TryParse(Request.QueryString["nID"].ToString(), out nID) && nID > 0)
         {
             lblBigtitle.Text  = "编辑数据";
             BtnAdd.Visible    = false;
             btnUpdate.Visible = true;
             DBLL.clsUser clUser = new DBLL.clsUser();
             DataTable    dt     = clUser.Select_tb_UserBynUserID(nID);
             if (dt != null && dt.Rows.Count > 0)
             {
                 hfID.Value = dt.Rows[0]["nUserID"].ToString();
                 RadioButtonList2.SelectedValue = dt.Rows[0]["nUserType"].ToString();
                 txtsUsername.Text              = dt.Rows[0]["sUsername"].ToString();
                 txtsPassword0.Text             = dt.Rows[0]["sPassword"].ToString();
                 txtsPassword1.Text             = dt.Rows[0]["sPassword"].ToString();
                 RadioButtonList1.SelectedValue = dt.Rows[0]["nUserSex"].ToString();
                 txtsRealName.Text              = dt.Rows[0]["sRealName"].ToString();
                 txtsUserQQ.Text    = dt.Rows[0]["sUserQQ"].ToString();
                 txtsUserMSN.Text   = dt.Rows[0]["sUserMSN"].ToString();
                 txtsUserPhone.Text = dt.Rows[0]["sUserPhone"].ToString();
                 txtsUserEmail.Text = dt.Rows[0]["sUserEmail"].ToString();
                 //绑定数据
             }
         }
         else
         {
             lblBigtitle.Text  = "添加数据";
             btnUpdate.Visible = false;
             BtnAdd.Visible    = true;
         }
     }
 }