protected void GvUpdating(object sender, GridViewUpdateEventArgs e) { int id; if (int.TryParse(string.Format("{0}", e.Keys["p_Id"]), out id)) { comm_sqlDataContext mylinq = new comm_sqlDataContext(); Peoples .Where(x => x.p_Id == id) .ToList() .ForEach(x => { x.p_type = string.Format("{0}", e.NewValues["p_type"]); x.p_subtype = string.Format("{0}", e.NewValues["p_subtype"]); x.p_lastname = string.Format("{0}", e.NewValues["p_lastname"]); x.p_firstname = string.Format("{0}", e.NewValues["p_firstname"]); x.p_middlename = string.Format("{0}", e.NewValues["p_middlename"]); x.p_post = string.Format("{0}", e.NewValues["p_post"]); x.p_email1 = string.Format("{0}", e.NewValues["p_email1"]); x.p_email2 = string.Format("{0}", e.NewValues["p_email2"]); x.p_room = string.Format("{0}", e.NewValues["p_room"]); x.p_phone1 = string.Format("{0}", e.NewValues["p_phone1"]); x.p_phone2 = string.Format("{0}", e.NewValues["p_phone2"]); x.p_phone3 = string.Format("{0}", e.NewValues["p_phone3"]); int bb = mylinq.updaterow(x.p_type, x.p_subtype, x.p_lastname, x.p_firstname, x.p_middlename, x.p_post, x.p_email1, x.p_email2, x.p_room, x.p_phone1, x.p_phone2, x.p_phone3, id); }); gv.EditIndex = -1; UpdateGrid(); } }
protected void okedit(object sender, EventArgs e) { People ff = Peoples[Convert.ToInt32(e_id.Value)]; Table1.Rows[0].Cells[0].Text = add_lastname.Text + " " + add_firstname.Text + " " + add_middlename.Text; Table1.Rows[1].Cells[0].Text = add_type.Text; Table1.Rows[2].Cells[0].Text = add_subtype.Text; Table1.Rows[2].Cells[1].Text = add_room.Text; Table1.Rows[3].Cells[0].Text = add_post.Text; Table1.Rows[4].Cells[1].Text = add_phone1.Text; Table1.Rows[5].Cells[1].Text = add_email1.Text; Table1.Rows[6].Cells[1].Text = add_phone2.Text; Table1.Rows[7].Cells[1].Text = add_phone3.Text; Table1.Rows[8].Cells[1].Text = add_email2.Text; int id; if (int.TryParse(string.Format("{0}", ff.p_Id), out id)) { comm_sqlDataContext mylinq = new comm_sqlDataContext(); Peoples .Where(x => x.p_Id == id) .ToList() .ForEach(x => { x.p_type = string.Format("{0}", add_type.Text); x.p_subtype = string.Format("{0}", add_subtype.Text); x.p_lastname = string.Format("{0}", add_lastname.Text); x.p_firstname = string.Format("{0}", add_firstname.Text); x.p_middlename = string.Format("{0}", add_middlename.Text); x.p_post = string.Format("{0}", add_post.Text); x.p_email1 = string.Format("{0}", add_email1.Text); x.p_email2 = string.Format("{0}", add_email2.Text); x.p_room = string.Format("{0}", add_room.Text); x.p_phone1 = string.Format("{0}", add_phone1.Text); x.p_phone2 = string.Format("{0}", add_phone2.Text); x.p_phone3 = string.Format("{0}", add_phone3.Text); int bb = mylinq.updaterow(x.p_type, x.p_subtype, x.p_lastname, x.p_firstname, x.p_middlename, x.p_post, x.p_email1, x.p_email2, x.p_room, x.p_phone1, x.p_phone2, x.p_phone3, id); }); gv.EditIndex = -1; UpdateGrid(); mylinq.Connection.Close(); } c_edit.Visible = true; c_ok.Visible = false; add.Visible = false; Table1.Visible = true; Table2.Visible = false; delete.Visible = true; }