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
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
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"); }
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"); }
Please mark you thread resolved using the Thread Tools as shown
Forum Rules