You are implementing an ASP.NET page that includes the following down list.
You need to dynamically add values to the end of the drop-down list. What should you do?
A.
Add the following OnPreRender event handler to the asp:DropDownList protected void
MyDropDown_PreRender(object sender, EventArgs e)
{
DropDownList ddl = sender as DropDownList;
Label lbl = new Label();
lbl.Text = “Option”;
lbl.ID = “Option”;
ddl.Controls.Add(lbl);
}
B.
Add the following OnPreRender event handler to the asp:DropDownList
protected void MyDropDown_PreRender(object sender, EventArgs e)
{
DropDownList ddl = sender as DropDownList;
ddl.Items.Add(“Option”);
}
C.
Add the following event handler to the page code-behind.
protected void Page_LoadComplete(object sender, EventArgs e)
{
DropDownList ddl = Page.FindControl(“MyDropDown”) as DropDownList;
Label lbl = new Label();
lbl.Text = “Option”;
lbl.ID = “Option”;
ddl.Controls.Add(lbl);
}
D.
Add the following event handler to the page code-behind.
protected void Page_LoadComplete(object sender, EventArgs e)
{
DropDownList ddl = Page.FindControl(“MyDropDown”) as DropDownList;
ddl.Items.Add(“Option”);
}
ssds