473,670 Members | 2,407 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ropdownlist listitem.value not working - returns listitem.text instead

I am populating a dropdownlist from SQL. The query returns the correct
values (and no NULLs in any fields). The listitem.value is populated
with an int ID field, and listitem.text with a varchar description
field. The problem is, for some reason, I cannot access the numeric ID
after item #5 in the dropdown box.
After item #5, if I try to read the ListItem.value, I get the
ListItem.text. If I run the query in Query Analyzer, I can see the
values all are there (none are NULL), and should be populated in the
dropdown. I am using VS.NET 2003 and SQL 2000. Has anyone seen an
error such as this? Is there a limit to the size of a dropdownlist? I
am using IE 6. Thanks...

Here is what I get when I traverse the dropdownlist contents:

Ordinal ListItem1.value ListItem1.text
------------------------------------------------
0001 -1 Select One ...
0002 98404 My List Item 1
0003 65370 My List Item 2
0004 89438 My List Item 3
0005 4440 My List Item 4
0006 My List Item 5 My List Item 5
0007 My List Item 6 My List Item 6
0008 My List Item 7 My List Item 7
....
0517 My List Item 516 My List Item 516
0518 My List Item 51 My List Item 517
Nov 18 '05 #1
2 2202
I've never met such problem, everything is ok in my app.

so can you paste the Dropdownlist loading code here, let's have a look.
I am populating a dropdownlist from SQL. The query returns the correct
values (and no NULLs in any fields). The listitem.value is populated
with an int ID field, and listitem.text with a varchar description
field. The problem is, for some reason, I cannot access the numeric ID
after item #5 in the dropdown box.
After item #5, if I try to read the ListItem.value, I get the
ListItem.text. If I run the query in Query Analyzer, I can see the
values all are there (none are NULL), and should be populated in the
dropdown. I am using VS.NET 2003 and SQL 2000. Has anyone seen an
error such as this? Is there a limit to the size of a dropdownlist? I
am using IE 6. Thanks...

Here is what I get when I traverse the dropdownlist contents:

Ordinal ListItem1.value ListItem1.text
------------------------------------------------
0001 -1 Select One ...
0002 98404 My List Item 1
0003 65370 My List Item 2
0004 89438 My List Item 3
0005 4440 My List Item 4
0006 My List Item 5 My List Item 5
0007 My List Item 6 My List Item 6
0008 My List Item 7 My List Item 7
...
0517 My List Item 516 My List Item 516
0518 My List Item 51 My List Item 517

Nov 18 '05 #2
Found the problem.
This behavior was caused by a NULL value getting stuck into the 6th
element's ListItem.value field. All elements in the dropdown after
that came up NULL, even if I had explicitly assigned them a value.

So anyone with dropdown list problems, remember to check for
* non-unique ListItem.values
* NULL ListItem.values
Nov 18 '05 #3

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

Similar topics

3
8888
by: tornado | last post by:
Hi all, I am pretty new to PHP. I was reading PHP manual and trying out the example from 2nd chapter (A simple Tutorial). When i try to print the variable as given in the example it returns a empty value instead of returning the browser type. Here is the line which i am using in my code and from manual: <?php echo $_SERVER; ?>
21
3963
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
4
9590
by: mg | last post by:
How can I change the color of the display text beside a single ListItem of a RadioButtonList when the associated radiobutton is selected - hopefully using C# in the codebehind of a WebForm? <asp:RadioButtonList id="RadioButtonList1" ........ > <asp:ListItem Value="Yes">Yes</asp:ListItem> <asp:ListItem Value="No">No</asp:ListItem> <asp:ListItem Value="Maybe">Maybe</asp:ListItem> </asp:RadioButtonList>
4
6516
by: Shaul Feldman | last post by:
Hello, I have something really awkward at work - fighting with CheckBoxList... How can I define CSS for ListItem in CheckBoxList programmatically. I add CheckBoxList's Items on the fly, something like dim li as ListItem li = new ListItem("title","value"); '' how to define here the CSS for List Item, not CheckBoxList?!?!?! myCheckBoxList.Items(x).add(li);
4
2304
by: Harold | last post by:
I have read the following article http://www.4guysfromrolla.com/webtech/073101-1.shtml. I added the empty selection as the first option. When I click submit without choosing anything it does not return my empty string but the 2nd value in listbox. When the page reloads it selects the 2nd option by default even thou my Empty field is in the list. What do I have to do to get the empty field and databound data to act as one?
4
1833
by: Sparky Arbuckle | last post by:
I am looping through a listbox collection to build a SQL string that will be used to delete items from a database. I have tried many variances of the code below but have had no luck. The code below gives an error: Cast from type 'ListItem' to type 'String' is not valid. When i do a response.write(s) the item at the top row displays correctly. Here is the code I am using:
3
2398
by: Nathan Sokalski | last post by:
I want to change the background color, font attributes, etc. of the choices in my DropDownLists. When writing them using HTML SELECT and OPTION tags, I can do something like the following: <option style="font-weight:bold;color:green;background-color:purple;">Displayed Text</option> but the ListItem Control does not have a Style property, which prevents me from doing anything other than specifying the Text, Value, and Selected
4
4677
by: Kevin Blount | last post by:
As mentioned before, I'm creating a multi-lingual page where the text of the page comes from a database. This page includes a registration form which asks for address information, including the Country. I have 6 .txt files that contain a complete list of countries that we sell to (65 in total), each written in the appropriate way for the language of the site, e.g. Mexico for English US and UK sites and México for the Spanish language...
5
37911
by: ssmeshack | last post by:
Hi All, Im using VWD 2008 (c#), I have a question here. Im having a dropdownlist like this: <asp:DropDownList ID="ddlIssue" runat="server" AutoPostBack="True" Height="24px" onselectedindexchanged="DropDownList2_SelectedIndexChanged" style="font-family: 'Arial'; font-size: small;" Width="170px"> <asp:ListItem></asp:ListItem>
0
8384
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8901
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
8813
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
8591
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,...
0
8659
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6212
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
4208
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...
0
4388
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2037
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.