Exemplo n.º 1
0
 /// <summary>
 /// 修改一行时执行
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void GuestTable_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     SqlDataSource1.UpdateCommand = "SELECT * FROM HOTEL WHERE hID='-1'";
     if (!Regex.IsMatch(e.NewValues["gID"].ToString(), "\\d{14}"))
     {
         //身份证号不为14位数字
         Response.Write("<script>alert('身份证号不正确!');</script>");
         return;
     }
     GuestManager.UpdateGuset(new Guest
     {
         Username  = UsernameLabel.Text,
         GuestID   = e.OldValues["gID"].ToString().Trim(),
         GuestName = e.OldValues["gName"].ToString()
     }, new Guest
     {
         Username  = UsernameLabel.Text,
         GuestID   = e.NewValues["gID"].ToString().Trim(),
         GuestName = e.NewValues["gName"].ToString()
     });
     GuestTable.DataBind();
 }