473,388 Members | 1,376 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,388 software developers and data experts.

why is the selectedvalue of this dropdownlist empty?

Hi,

This code sends back the selectedvalue of a dropdownlist to itself
(postabck).
But the value (dd in the code) is empty.
I must say: it works with EnableViewState="true".

My question is: dropdownlist control doesn't need viewstate for keeping the
value when the ListItems are put declaratively. Why not when the ListItems
are put programmatically?

Thanks
Bart
May 29 '07 #1
3 10729
if a select is declared declaratively, on postback the item values are
set in oninit by the code the form generates.

if you dynamically update the list, you need to also do it in oninit of
the postback.

if viewstate is enabled, the list is stored in viewstate, and the
control reloades the list in onviewstate load. also the render value is
saved, so the onchange event can be fired.

-- bruce (sqlwork.com)

Bart wrote:
Hi,

This code sends back the selectedvalue of a dropdownlist to itself
(postabck).
But the value (dd in the code) is empty.
I must say: it works with EnableViewState="true".

My question is: dropdownlist control doesn't need viewstate for keeping the
value when the ListItems are put declaratively. Why not when the ListItems
are put programmatically?

Thanks
Bart

May 29 '07 #2
If you put them in programmatically, in the page load, it reloads every time
the page posts back
You must surround the loading of the ddl with an postback block (if not
page.ispostback then...)

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://iWritePro.com

"Bart" <b@swrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Hi,

This code sends back the selectedvalue of a dropdownlist to itself
(postabck).
But the value (dd in the code) is empty.
I must say: it works with EnableViewState="true".

My question is: dropdownlist control doesn't need viewstate for keeping
the value when the ListItems are put declaratively. Why not when the
ListItems are put programmatically?

Thanks
Bart

May 29 '07 #3
Thanks to both

"David Wier" <da*******@davidwier.nospam.comschreef in bericht
news:ep**************@TK2MSFTNGP04.phx.gbl...
If you put them in programmatically, in the page load, it reloads every
time the page posts back
You must surround the loading of the ddl with an postback block (if not
page.ispostback then...)

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://iWritePro.com

"Bart" <b@swrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Hi,

This code sends back the selectedvalue of a dropdownlist to itself
(postabck).
But the value (dd in the code) is empty.
I must say: it works with EnableViewState="true".

My question is: dropdownlist control doesn't need viewstate for keeping
the value when the ListItems are put declaratively. Why not when the
ListItems are put programmatically?

Thanks
Bart


May 30 '07 #4

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

Similar topics

15
by: Swetha | last post by:
Hello I have a DropDownList that I am populating using the following SqlDataSource: <asp:DropDownList ID="parentIDDropDownList" runat="server" DataSourceID="SqlDataSource3"...
2
by: Dabbler | last post by:
In my Registrant FormView I have a DropDownList which loads data from a secondary SqlDataSource "sdsOfficeParks". I need the user to select an office park but save the selected value in the...
1
by: clickon | last post by:
Forget about the controlParameter for the moment, for testing purposes i have created the following Markup: <asp:Table ID="tblSelectRoute" runat="server" CssClass="asp-table"> <asp:TableRow>...
0
by: Ben | last post by:
Hi, It's about a database containing (for simplifying) three fields: 'placenr' (primary key), 'place' and 'color'. The records are updatable (Edit/Update button) in a gridview. For updating the...
2
by: sree reddy | last post by:
..cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls;
3
by: Bernard Borsu | last post by:
I've a problem with selectedvalue from a dropdownlist. I've migrated a web page from asp.net 1.1 to 2.0. Everything worked fine in asp.net 1.1. When postback occurs, no values left in the...
18
by: Redhairs | last post by:
Is it possible to get DropDownList.SelectedValue in Page_PreInit() event during the postback?
18
by: Ben | last post by:
Hi, i dynamically feed a dropdownlist which value from 1 to 20. That dropdownlist is bound to field 'wa' (type nvarchar(4)) in 'mytable'. There are 4 records and the values of field 'wa' are: 2...
1
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.