private bool saveData() { bool blnResult = false; string strUpdatedBy = string.Empty; string struser_group_list = string.Empty; strUpdatedBy = Session["username"].ToString(); CheckBox chkSelect; HiddenField hddg_code; foreach (GridViewRow gvRow in GridView1.Rows) { chkSelect = (CheckBox)gvRow.FindControl("chkSelect"); hddg_code = (HiddenField)gvRow.FindControl("hddg_code"); if (chkSelect.Checked) { struser_group_list += hddg_code.Value + ","; } } if (struser_group_list.Length > 0) { struser_group_list = struser_group_list.Substring(0, struser_group_list.Length - 1); } var objUser = new cUser(); try { #region update if (objUser.SP_PERSON_USER_GROUP_UPD(hddperson_code.Value, struser_group_list, strUpdatedBy)) { blnResult = true; } #endregion } catch (Exception ex) { lblError.Text = ex.Message; } finally { objUser.Dispose(); } return(blnResult); }