protected void btnSubmit_Click(object sender, EventArgs e) { int ContactID = int.Parse(Request.QueryString["ID"].ToString()); int UserID = Global.UserInfo.UserID; BContact Bobj = new BContact(); string FullName = txtFullName.Text; CultureInfo culture = new CultureInfo("fr-FR", true); DateTime BirthDay = DateTime.Parse(txtBirthDay.Text, culture, DateTimeStyles.NoCurrentDateDefault); string ContactName = ""; string TitleName = ddlXungDanh.SelectedValue; string Phone = txtPhone.Text; string Tel = txtTel.Text; string Gender = ddlGender.SelectedValue.ToString(); string Job = txtJob.Text; string Address = txtAddress.Text; string Other = txtOther.Text; int ContactGroup = int.Parse(ddlContactGroup.SelectedValue); string Email = txtEmail.Text; if (Bobj.Update(ContactID, ContactName, FullName, TitleName, Phone, Tel, BirthDay, Gender, Job, Address, ContactGroup, UserID, Other, Email)) { lblThongBao.Text = "Cập nhật thành công!"; } }
protected void grvContact_RowUpdating(object sender, GridViewUpdateEventArgs e) { int UserID = Global.UserInfo.UserID; int Id = Convert.ToInt32(grvContact.DataKeys[e.RowIndex].Value); string textName = ((TextBox)grvContact.Rows[e.RowIndex].Cells[2].Controls[0]).Text; string textPhone = ((TextBox)grvContact.Rows[e.RowIndex].Cells[3].Controls[0]).Text; string textTel = ((TextBox)grvContact.Rows[e.RowIndex].Cells[4].Controls[0]).Text; string textEmail = ((TextBox)grvContact.Rows[e.RowIndex].Cells[5].Controls[0]).Text; string textAddress = ((TextBox)grvContact.Rows[e.RowIndex].Cells[6].Controls[0]).Text; BContact obj = new BContact(); if (obj.Update(Id, textName, textPhone, textTel, textAddress, textEmail, UserID)) //Lấy IDUSer sau { lblThongBao2.Text = "BẠN ĐÃ CẬP NHẬT THÀNH CÔNG DANH BẠ!"; } grvContact.EditIndex = -1; grvContact_Load(); }