protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { if (this.List == null) { throw new Exception("List not found"); } // init List name lblListName.Text = this.List.Name; // Add fields var allFields = this.List.ListMetadataContentTypes.SelectMany(ct => ct.ListMetadataFieldContentTypes.Select(ctf => new { ContentType = ct.Name, FieldId = ctf.ListMetadataFieldId, Field = ctf.ListMetadataField })); ColumnsRepeater.DataSource = allFields.GroupBy(g => g.FieldId).Select(g => new { Id = g.Key, FieldName = g.First().Field.FieldName, FieldType = g.First().Field.FieldType, UsedIn = string.Join(", ", g.Select(x => x.ContentType)) }).OrderBy(f => f.FieldName); ColumnsRepeater.DataBind(); // Add Content Types ContTypesRepeater.DataSource = this.List.ListMetadataContentTypes.OrderBy(ct => ct.IsDefault); ContTypesRepeater.DataBind(); // Add Views ViewsRepeater.DataSource = this.ListViews.OrderBy(f => f.Name); ViewsRepeater.DataBind(); // add 'List' url param to links string encodedListId = SPEncode.UrlEncode(this.ListGuid.ToString("B").ToUpper()); linkNewField.NavigateUrl += "?List=" + encodedListId; linkNewView.NavigateUrl += "?List=" + encodedListId; linkNewContentType.NavigateUrl += "?List=" + encodedListId; linkListPermissions.NavigateUrl += "?ListId=" + encodedListId; } catch (Exception ex) { panelErrror.Controls.Add(new Microsoft.SharePoint.Mobile.Controls.Label() { Text = ex.Message }); } } }
protected void Page_LoadComplete(object sender, EventArgs e) { ViewsRepeater.DataBind(); }