-
User Control
Hi!
I am developing an asp.net application using c#.
I have made a User Control which has a dropdownlist box. I have included that dropdownlist in my page through the following code in my page_load event.
Code:
Control myControl =(Control)Page.LoadControl (DropDownList.ascx");
Panel1.Controls.Add(myControl);
Now, I want to access the items of the dropdownlist in my page. How to do that.
Viewing source of the page shows me this:
HTML Code:
<select name="_ctl0:cboDataBase" id="_ctl0_cboDataBase" style="width:144px;">
<option selected="selected" value="gsportal">gsportal</option>
<option value="test">test</option>
</select>
-
Re: User Control
Add a wrapped property to your user control that exposes the Items Property of your ddl. Then simply
Code:
TheUserControl ctl = (TheUserControl)FindControl("itsid");
ctl.Item[0]....