protected void gvBlockList_RowUpdating(object sender, GridViewUpdateEventArgs e) { int result = 0; BlockList blo = new BlockList(); GridViewRow row = (GridViewRow)gvBlockList.Rows[e.RowIndex]; // int id = int.Parse(gvBlockList.SelectedRow.Cells[0].Text); int id = int.Parse(gvBlockList.DataKeys[e.RowIndex].Value.ToString()); // string tid = ((TextBox)row.Cells[0].Controls[0]).Text; // string userName = ((TextBox)row.Cells[1].Controls[0]).Text; // string gender = ((TextBox)row.Cells[2].Controls[0]).Text; // string dateOfBirth = ((TextBox)row.Cells[3].Controls[0]).Text; Boolean enabled = Convert.ToBoolean(((TextBox)row.Cells[5].Controls[0]).Text); result = blo.BlockListUpdate(id, enabled); if (result > 0) { Response.Write("<script>alert('BlockList updated successfully');</script>"); } else { Response.Write("<script>alert('BlockList NOT updated');</script>"); } gvBlockList.EditIndex = -1; bind(); }