/* Methods */ /// <summary> /// The bind data. /// </summary> private void BindData() { bool found = false; if (this.Request.QueryString.GetFirstOrDefault("r") != null) { // Load the page access list. var dt = LegacyDb.eventloggroupaccess_list(this.Request.QueryString.GetFirstOrDefault("r"), null); // Get admin pages by page prefixes. var listEnumValues = Enum.GetValues(typeof(EventLogTypes)); // Initialize list with a helper class. var adminPageAccesses = new List <GroupEventLogAccess>(); // Iterate thru all admin pages foreach (int eventValue in listEnumValues) { int eventTypeId = eventValue; foreach ( var dr in dt.Rows.Cast <DataRow>().Where(dr => dr["EventTypeID"].ToType <int>() == eventTypeId)) { found = true; adminPageAccesses.Add( new GroupEventLogAccess { GroupId = this.Request.QueryString.GetFirstOrDefault("r").ToType <int>(), EventTypeId = eventTypeId, EventTypeName = Enum.GetName(typeof(EventLogTypes), eventTypeId), DeleteAccess = dr["DeleteAccess"].ToType <bool>(), ViewAccess = true }); } // If it doesn't contain page for the user add it. if (!found) { adminPageAccesses.Add( new GroupEventLogAccess { GroupId = this.Request.QueryString.GetFirstOrDefault("r").ToType <int>(), EventTypeId = eventTypeId, EventTypeName = Enum.GetName(typeof(EventLogTypes), eventTypeId), DeleteAccess = false, ViewAccess = false }); } // Reset flag in the end of the outer loop found = false; } if (dt != null && dt.HasRows()) { this.GroupName.Text = this.HtmlEncode(dt.Rows[0]["GroupName"]); } // get admin pages list with access flags. this.AccessList.DataSource = adminPageAccesses.AsEnumerable(); } this.DataBind(); }