Dropdown is not maintaining itz state after postback

G

Guest

Hi,
Currently iam facing a strange problem.. One dropdown in my page is not
keeping itz state after postback. Whichever the item i select irrespective of
that after the post-back the default selected item is the first one. This
happens even if i submitted the page by making the AutoPostback of the
dropdown true or by clicking on the submit button.
Even it’s not going to the DropDownList1_SelectedIndexChanged method.

A checking is already there at page load event to avoid filling the dropdown
at the time of postback.

The items are populating from database. The interesting matter is, this
problem comes only when i fill the dropdown from the database. if iam hard
coding the items then this problem is not there. That time itz maintaining
the state.

Anybody hav any idea what may be the problem
 
G

Guest

I hav a method which connects to DB and populates the dropdown. i changed the
calling of method from page load to page init as per ur suggestion but now
the data is not populating. If i move the calling back to page load then it
populates.
any idea what wrong with my code ?
 
M

Mark Rae

any idea what wrong with my code ?

Almost certainly because you haven't actually wired up Page_Init...

1) Open up the Web Form Designer generated code section

2) Open up the InitializeComponent method

3) Wire up the Page_Init method as well as the Page_Load method e.g.

this.Init += new System.EventHandler(this.Page_Init);
this.Load += new System.EventHandler(this.Page_Load);
 

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

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top