c# – Getting values of dynamically added controls in ASP.NET – Education Career Blog

hello everyone thank you so much for providing help to me for my previous question as I’m developing application for education domain. In that I take panel control as panel1 and define a few dropdownlist controls in that panel as dropdown1, dropdown2 etc. dynamically in button1 click event and i want to use those controls’ values in button2 click event help me for the same.


In button2_Click event, you can get dropdown’s values as :

DropDownList ddl1 = (DropDownList)Page.FindControl("dropDownList1");
string dropdown1value = ddl1.SelectedValue;

But after second postback, your dynamically added controls will be lost. so you should add them in page’s init event not in first button’s click event.

Leave a Comment