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
  • I don't understand your explanation. Could you add to it or give an example? Commented Apr 5, 2009 at 17:46

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.