DropdownLisr problem on postback

  • Thread starter Herman Geovany Ayala Zúñiga
  • Start date
H

Herman Geovany Ayala Zúñiga

Hi.

I working with dropdownlist control, this control is populated with a
collection. when the page has a postback i tried to get the new
selectedindex that the user select but always is 0. What happening? What
can i do? this control doný fire teh postback.

Regards
 
C

Chison Cai

HI,
Is it running the "DataBinding" code to re-bind the dropdownlist when
the page is postback ?
 
H

Herman Geovany Ayala Zúñiga

Chison Cai escribió:
HI,
Is it running the "DataBinding" code to re-bind the dropdownlist when
the page is postback ?
I do that to populate again the dropdownlist but i want to get the
selectedindex when the postback fires

regards
 
C

Chison Cai

You should NOT re-bind the dropdownlist when the page is postback...
cos it will refresh the dropdownlist's DataSource and reset the
selectedindex to 0 .

you just need to have data binded when the page is not PostBack.
like this:

private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
//binding dropdownlist
}
}

holp it helps

Regards,
chison
 

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

Members online

No members online now.

Forum statistics

Threads
474,257
Messages
2,571,032
Members
48,768
Latest member
first4landlord

Latest Threads

Top