I will be creating a web part that enumerates root site and all it's subsites content types along with their columns.
We will be using a Tree View control for this.
| using System; using System.Web.UI; using Microsoft.SharePoint; /// <summary> foreach (SPContentType conttype in oCTypeColl) //add columns //now oSubNode is the parent node } /// <summary> //fetch fields of content type if (oFldColl.Count != 0) foreach (SPField oField in oFldColl) } /// <summary> //get the name of the current web in current user's context string spSiteURL = SPControl.GetContextSite(Context).Url.ToString(); //Initialize the spweb object using the elevated privileges #region Add content types TreeNode oSiteNode = null; //get contenttypes collection for each subsite including root site //if site doesn't have any Ctypes (only content types defined for that particular site are displayed) //send current site and root contenttype node (not the actual content type) //add root contenttype node to website node }
TreeView1.CollapseAll(); } protected override void OnPreRender(EventArgs e) protected override void CreateChildControls() { protected override void RenderContents(HtmlTextWriter writer) } |