473,738 Members | 1,949 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 ListItemCollect ion
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 ListItemCollect ions 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 2094
Why create ListItems?

If you use

ddlObject.DataS ource = dataobject;
ddlObject.DataT extField = "Field_Name_To_ Show_Text";
ddlObject.DataV alueField= "Field_Name_To_ Store_In_Value" ;
ddlObject.DataB ind();

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 ListItemCollect ion
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 ListItemCollect ions 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
5482
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 dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
2
3120
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 is performed. How do I force the usercontrol to display the newly assigned date? I don't have this problem if I place the two dropdownlist and the year field directly on the aspx page.
18
2451
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 textbox, and in the second row I need to bind data into a dropdownlist...It all depends on the data I select from the database. I cannot use TemplateColumn because it has to be the same type of control for one column.
2
3049
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.. only the labels (caption) and the invisible literal controls are binded.. Now based on the invisible literal control values I get the information from DB to bind it with each dropdown list (I am doing this in the item databound event) Also based on...
6
5406
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 its AutoPostBack set to true and has its SelectedIndexChanged event being handled in codebehind. The event fires as it should populating two more ddls. The problem is, the two ddls appear empty. I have used a javascript alert to look at the...
11
5811
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
5
13052
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 (selectedindexchanged). I have tried adding an onchange attribute "return confirm('sure u wanna change this?';") but it will not postback regardless of the confirm result and the value in the list does not revert back if cancel selected. Is there a solution?
11
4468
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 following works fine on IE: document.getElementById('dropdown').options.selected = 0 //
18
5431
by: Redhairs | last post by:
Is it possible to get DropDownList.SelectedValue in Page_PreInit() event during the postback?
0
8968
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9473
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9334
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9259
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6750
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4569
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3279
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 we have to send another system
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.