473,396 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Dynamic dropdownlist and postBack ...

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.
Sep 17 '07 #1
2 1684
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" <francois@corebridgecomwrote in message
news:uA****************@TK2MSFTNGP04.phx.gbl...
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.

Sep 17 '07 #2
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" <RE**************************@mMvVpPsS.orga écrit dans le
message de news: uh****************@TK2MSFTNGP06.phx.gbl...
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" <francois@corebridgecomwrote in message
news:uA****************@TK2MSFTNGP04.phx.gbl...
>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.


Sep 17 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike | last post by:
I create a dynamic control and added it to a panel. I get the selected value of the control via a btn_click() but my problem is everytime the page is postback the selected values go back to the...
6
by: hb | last post by:
Hi, I have a page bill.aspx and its code-behind bill.aspx.cs. On bill.aspx I have: === Select a month: <asp:dropdownlist runat="server" id="lstDate" autopostback="True" /> <br> <asp:table...
6
by: Jason | last post by:
I have two drop down lists on my asp.net page, the second of which needs to be filled in based on the selection in the first dropdownlist. The catch however, is that it must occur without a...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
5
by: vcuankitdotnet | last post by:
Hi. I have tried to search for this online, but can't find what I'm looking for so I decided to come here. I have a ASP.NET 2.0 website with a masterpage. My .aspx page uses the masterpage. Here is...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
4
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
I have a WebForm where I'm dynamically creating some controls and I'm having difficulty understanding how the state is being persisted and how to work with it. I've created a simplified example...
6
by: shashi shekhar singh | last post by:
Respected Sir, I have to create multiple dynamic dropdownlist boxes and add items dynamically in <asp:table> server control but problem occurs , i.e. except of fist dropdown list no dropdownlist...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.