protected void OnRowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GridView_department.Rows[e.RowIndex]; string deptcode = Convert.ToString(GridView_department.DataKeys[e.RowIndex].Values[0]); string deptname = (row.FindControl("TextBox1") as TextBox).Text; string contacttitle = (row.FindControl("TextBox2") as TextBox).Text; string contactname = (row.FindControl("TextBox3") as TextBox).Text; string phone = (row.FindControl("TextBox4") as TextBox).Text; string fax = (row.FindControl("TextBox5") as TextBox).Text; string headtitle = (row.FindControl("TextBox6") as TextBox).Text; string headname = (row.FindControl("TextBox7") as TextBox).Text; string collectionpoint = (row.FindControl("TextBox8") as TextBox).Text; string repname = (row.FindControl("TextBox9") as TextBox).Text; Departmentcode = deptcode; List <string> list = new List <string>() { deptcode, deptname, contacttitle, contactname, phone, fax, headtitle, headname, collectionpoint, repname }; foreach (string c in list) { if (c == "" || c == null) { Session["count"] = 1; } } if (Convert.ToInt32(Session["count"]) == 1) { Label11.Text = "Infomation is not complete"; Session["count"] = 0; } else { StoreBusinessLogic.EditDepartment(deptcode, deptname, contactname, phone, fax, headname, collectionpoint, repname, contacttitle, headtitle); GridView_department.EditIndex = -1; bindgrid(); btn_Inform.Enabled = true; Btn_addNew.Enabled = true; } }