protected void SaveGroups(DetailsView dv, SRPUser obj) { GridView gv = (GridView)dv.FindControl("gvUserGroups"); string memberGroups = string.Empty; foreach (GridViewRow row in gv.Rows) { if (((CheckBox)row.FindControl("isMember")).Checked) { memberGroups = string.Format("{0},{1}", memberGroups, ((Label)row.FindControl("GID")).Text); } } if (memberGroups.Length > 0) { memberGroups = memberGroups.Substring(1, memberGroups.Length - 1); } SRPUser.UpdateMemberGroups((int)obj.Uid, memberGroups, ((SRPUser)Session[SessionData.UserProfile.ToString()]).Username); }