tags:

views:

86

answers:

1

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.

+1  A: 

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.

Canavar
That should read panel1.FindControl("dropDownList1") . If I'm not mistaken, FindControl() only scans first degree child controls.
SirDemon
@SirDemon : No, Page.FindControl returns controls that are child of another control.
Canavar
actually i tried bt it gves an error dat "Object reference not set to an instance of an object."