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_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    if (this.ContentType == null)
                    {
                        throw new Exception("Content Type not found");
                    }

                    // init Content Type name
                    lblContentTypeName.Text = this.ContentType.Name;

                    // Add fields
                    ColumnsRepeater.DataSource = this.ContentType.ListMetadataFieldContentTypes.OrderBy(f => f.ItemPosition).Select(f => f.ListMetadataField);
                    ColumnsRepeater.DataBind();

                    // add 'ContentType' url param to links
                    string encodedContentTypeId = SPEncode.UrlEncode(this.ContentTypeId.ToString());
                    linkFormSettings.NavigateUrl   += "?ContentType=" + encodedContentTypeId;
                    linkNewField.NavigateUrl       += "?ContentType=" + encodedContentTypeId;
                    linkFieldsOrdering.NavigateUrl += "?ContentType=" + encodedContentTypeId;
                    linkAddField.NavigateUrl       += "?ContentType=" + encodedContentTypeId;

                    // add 'List' url param to links
                    string encodedListId = SPEncode.UrlEncode(this.ContentType.ListMetadataId.ToString("B").ToUpper());
                    linkNewField.NavigateUrl += "&List=" + encodedListId;

                    btnDelete.Visible = !this.ContentType.IsDefault;
                }
                catch (Exception ex) {
                    panelErrror.Controls.Add(new Microsoft.SharePoint.Mobile.Controls.Label()
                    {
                        Text = ex.Message
                    });
                }
            }
        }