Cannot access WebControls.DropDownList value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a pop-up window in which I have 3 WebControls.DropDownList controls.
I make my selections and when I submit the page, in the code behind page one
control has the right value for SelectedIndex and SelectedValue properties,
but the other two controls have values like I did not make any selections in
them.
The only difference between the controls is that the one that's working is
defined in the page using <asp:ListItem Value="NY">, the other two are
DataBound to a stored procedure.
I don't understand what's wrong.
Any thoughts?
Thank you.
 
On postback you are probably rebinding the dropdownlist which is effectively
overwriting the selection you made, wrap the binding code in an if not
Page.IsPostBack THEN
such as:

if (!Page.IsPostBack){
ddl1.DataSource = GetSource();
ddl1.DataBind();
}

Karl
 
Back
Top