Dynamic dropdownlist and postBack ...

F

Francois

Hello,

ASP NET 2.0 visual studio 2005.

I am tryng to create a dynamic dropdownlist in the Page_Load event.

myDDL = new DropDownList

I populate it in the IsPostBack branch of Page_Load.

myDDL.DataSource = ArrayList ...
myDDL.DataBind();


When the page is called back after a click, the dropdownlist comes back
empty,
I have myDDL.SelectedValue = "" ;

I have no problem with other textBox.

Of course, EnableViewState = true.


What should I check for ?

Thanks.

François.
 
F

Francois

I tried Page_Init and Page_PreInit to no result.

I tried SelectedIndexChanged, but it did not fire.

The only thing that changed something was to repopulate the list in
Page_Lod, by using myDDL.Items.Add. And then it only worked for the next
PosyBack.

Later PostBack no longer change the value.

Thanks.

Eliyahu Goldin said:
Move this line
myDDL = new DropDownList
into Page_PreInit event.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Francois said:
Hello,

ASP NET 2.0 visual studio 2005.

I am tryng to create a dynamic dropdownlist in the Page_Load event.

myDDL = new DropDownList

I populate it in the IsPostBack branch of Page_Load.

myDDL.DataSource = ArrayList ...
myDDL.DataBind();


When the page is called back after a click, the dropdownlist comes back
empty,
I have myDDL.SelectedValue = "" ;

I have no problem with other textBox.

Of course, EnableViewState = true.


What should I check for ?

Thanks.

François.
 

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

Top