protected void Page_Load(object sender, EventArgs e) { if (!this.LoadData()) { return; } if (this.Page.IsPostBack) { return; } this.lblGroupNameCn.Text = this.CurrentDataItem.GroupNameCn.ToString(); this.lblGroupNameEn.Text = this.CurrentDataItem.GroupNameEn.ToString(); this.lblGroupDescription.Text = this.CurrentDataItem.GroupDescription.ToString(); this.dgAssignedRole.DataSource = systemRoleServiceInstance.FindAll(); this.dgAssignedRole.DataBind(); List <int> roleIDList = systemUserGroupServiceInstance.GetUserGroupAssignedroleIDList(this.CurrentDataItem); foreach (DataListItem item in this.dgAssignedRole.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { CheckBox chk = (CheckBox)item.FindControl("chkAssignedRole"); if (chk != null) { chk.Checked = roleIDList.Contains(int.Parse(chk.Attributes["value"])); } } } }