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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top