Guys,
I am populating a dropdownlist and adding it to a placeholder at runtime. How can I get to events of the drop down?
Ta
Bob
Printable View
Guys,
I am populating a dropdownlist and adding it to a placeholder at runtime. How can I get to events of the drop down?
Ta
Bob
Add a event handler to the control as illustrated
Code:protected void Page_Load(object sender, EventArgs e)
{
DropDownList ddl=new DropDownList();
ddl.AutoPostBack=true;
ddl.Items.Add("Line1");
ddl.Items.Add("Line2");
Panel1.Controls.Add(ddl);
ddl.SelectedIndexChanged+=new EventHandler(ddl_SelectedIndexChanged);
}
protected void ddl_SelectedIndexChanged(object sender,EventArgs e)
{
Response.Write("PostBackOccurs");
}