Dynamically populate the controls in a custom Web Part for SharePoint 2010

While working a custom web part in sharePoint 2010, came across a interesting issue where i had to load controls dynamically based on the value in a drop down control. If i load the controls in the index changed event for the drop down then i would be unable to access thier poperties later in the code.
As all the controls aare stored in the Page.Request, in the CreateChildControls i used Page.Request[lstServcices.UniqueID]  to get the value of the drop down.
After checking that the value in the Page.Request[lstServices.UniqueID] was not null, i wrote the code for creating the dynamic controls. Make sure that you use control..UniqueID, which is a combination of $$$,  and not Control.ID.

Comments

Popular posts from this blog

Print from WPF using ReportViewer Control

Printing SSRS 2008 R2 Reports from C#.

Using IOptions class in .Net Core Unit Testing.