473,508 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dropdownlist value is same as text after postback and in HTML (2.0

I'm converting this project from ASP.NET 1.1 to 2.0, and the thing I came
across is that my dropdownlist no returns the content of the Value property
in a correct way. I'm not using a direct Database connection or anything,
most of my dropdownlists are filled with values from static singletons that
are running or just some code that is generated at page_load.

The basic thing is that on page_load I always create a ListItemCollection
containing the items I want. The items have different content for Value and
Text. When using the debugger it is very clear that on creation my ListItems
are created as I want them. On PostBack however (the ListItemCollections are
not re-generated on postback) the ListItems in the dropdownlist contain the
same content for Value and Text (this is always the original content of
Text). So I am unable to locate the original Value these items had. YES, I
have EnableViewState set to true and NO it's not an option to re-generate the
collections after every postback. Why doesn't this normal feature work in
ASP.NET 2.0? I have tested it on 2 enviroments (local workstation and a
testserver), both indicate the same problem.

Under ASP.NET 1.1 this just works as it should.
Mar 12 '06 #1
1 2084
Why create ListItems?

If you use

ddlObject.DataSource = dataobject;
ddlObject.DataTextField = "Field_Name_To_Show_Text";
ddlObject.DataValueField= "Field_Name_To_Store_In_Value";
ddlObject.DataBind();

I'm sure that works perfectly in both 1.1 and 2.0.

HTH

Elton Wang

"Geoffrey van den Ouden" wrote:
I'm converting this project from ASP.NET 1.1 to 2.0, and the thing I came
across is that my dropdownlist no returns the content of the Value property
in a correct way. I'm not using a direct Database connection or anything,
most of my dropdownlists are filled with values from static singletons that
are running or just some code that is generated at page_load.

The basic thing is that on page_load I always create a ListItemCollection
containing the items I want. The items have different content for Value and
Text. When using the debugger it is very clear that on creation my ListItems
are created as I want them. On PostBack however (the ListItemCollections are
not re-generated on postback) the ListItems in the dropdownlist contain the
same content for Value and Text (this is always the original content of
Text). So I am unable to locate the original Value these items had. YES, I
have EnableViewState set to true and NO it's not an option to re-generate the
collections after every postback. Why doesn't this normal feature work in
ASP.NET 2.0? I have tested it on 2 enviroments (local workstation and a
testserver), both indicate the same problem.

Under ASP.NET 1.1 this just works as it should.

Mar 13 '06 #2

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

Similar topics

4
5449
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
2
3100
by: Benedict Teoh | last post by:
I created a dropdownlist containing day, month and year field and expose a property to assign a date. When I call from a aspx page and assign the value, the new date is not displayed until a submit...
18
2423
by: Julia Hu | last post by:
Hi, I have a datagrid, and in different rows I need to programmatically bind different type of controls and load data into these controls. For example,in the first row I need to bind data into a...
2
3034
by: Shiju Poyilil | last post by:
Hi ! I have a requirement wherein i am binding a datalist which contains a label (Caption for the field) and some literal hidden fields and a dropdown list. When I am binding to the datalist.....
6
5388
by: Scott Lee | last post by:
I am displaying an ASP.Net generated form in a popup opened with window.showModalDialog. The form contains DropDownList controls. The first ddl is populated via databinding to a datatable, has...
11
5787
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
5
13033
by: robert | last post by:
I have a dropdownlist with the autopostback set to true. I want the user to be confirm whether they do indeed want to change the value, which on post back fires a server side event...
11
4448
by: harold.gimenez | last post by:
Hi group, I am trying to change the selection of an ASP Dropdownlist just like "Orange" is selected here: http://www.w3schools.com/js/tryit.asp?filename=try_dom_option_selected The...
18
5409
by: Redhairs | last post by:
Is it possible to get DropDownList.SelectedValue in Page_PreInit() event during the postback?
0
7223
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
7377
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
7489
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...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1547
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.