I want to add items to my drop down in function addItems. How to do that at runtime?
<asp:DropDownList ID="DropDownNum" runat="server" Width="50px" SelectedValue='<%#Bind("num")%>' OnLoad='addItems'>
</asp:DropDownList>
protected void addItems() {
...
foreach (NumOption option in ConfigManager.Config.NumOptions.Options)
{
numDropDown.Items.Add(option.Value);
}
}
edit: I need to get the instance of the DropDownList to call it via numDropDown, the adding itself is not the problem
You can add items like…
Edit: In reference your comments, you are unable to get the Control reference in your code class. You have to find the control in the particular container e.g.
Note: where Container is the control in your dropdownlist