Take the 2-minute tour ×

i have tow dropdownlists in formview when i select from the first dropdownlist i take the value and postback to the same page with this line response.redirect("addtabs.aspx?SECID="+dropdownlist1.selected value.tostring()) and thi second dropdownlist take th SECID and fill it self with sqldatasource with this parameter every thing ok but when post back the first dropdownlist doesn't select my choise but select the first item in it how can i make it still select my selection

share|improve this question

1 Answer 1

Are you populating the dropdownlists in the Page_Load method? If so, then you'll want to wrap that logic in a conditional such as if (!IsPostBack). Page_Load gets executed on a postback before the event being fired gets executed (such as the button_click handler). So it would over-write the selected value when it re-populates the dropdownlist.

share|improve this answer
No the first dropdownlist populate with sqldatasource within a formview i ahvent a control to it –  user514492 Nov 20 '10 at 14:27
@user514492: Well, whether you're writing code or using pluggable widgets the behavior seems to be the same. The controls are re-binding to their data on postback. What code is in your Page_Load method? Also, here's a post you may find useful: forums.asp.net/p/1540056/3751956.aspx –  David Nov 20 '10 at 14:38

Your Answer


