Hello,
You can add a drop down list and the CMSRepeater controls to the web part:
<asp:DropDownList runat="server" ID="ddl" AutoPostBack="true" OnSelectedIndexChanged="OnSelectedIndexChanged" ></asp:DropDownList>
<cms:CMSRepeater runat="server" ID="rep" TransformationName="cms.news.default" HideControlForZeroRows="true" ></cms:CMSRepeater>
Within the Page_Load method, you can bind the drop-down list control with data set as shown here:
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
DataSet ds = tree.SelectNodes(CMSContext.CurrentSiteName, "/%", "en-us", false, "cms.news");
if (!DataHelper.DataSourceIsEmpty(ds))
{
ddl.DataSource = ds;
ddl.DataTextField = "DocumentName";
ddl.DataValueField = "DocumentID";
ddl.DataBind();
}
The drop down list control provides the
OnSelectedIndexChanged handler in which you can access the selected DocumentID, get the TreeNode object and bind the CMSRepeater control:
protected void OnSelectedIndexChanged (object sender, EventArgs e)
{
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
TreeNode node = DocumentHelper.GetDocument(ValidationHelper.GetInteger(ddl.SelectedValue, 0), tree);
rep.DataSource = node.GetDataSet();
rep.DataBind();
}
Anyway, you should also consider caching returned data set of documents to improve performance:
Caching API examples.
Moreover, more information about developing web parts, can be found here:
Developing web partsI hope this will help you.
Best regards,
Michal Legen