C#/passing values from a usercontrol to another page
Expert: Srini Nagarajan - 3/27/2005
Questionhello,
i have created a user control which has 2 dropdownlists .
on clickig the submit button i want to pass the values of the dropdownlists to another page but when i do this i always seem to pass the values of the default options selected in the 2 dropdownlists.
the code is below;
String strURL;
strURL="search_details.aspx?location=" + ddlLocation.SelectedItem.Value + "&state=" + ddlTypeDesc.SelectedItem.Value;
Response.Redirect(strURL);
Any assistance would be appreciated..
thx
AnswerHi
It's important to know which events are fired when a user changes the dropdownlist.
First, in the Page_Load, you should check for a postback. If it's a postback, then don't bind data to the dropdownlist. This will prevent the user input to be overwritten.
After that, create an event handler for the Drop down list changed, In this event, you can get the selected index in your dropdownlist.
Happy Programming!!
-Srini