Hi,
Please add these lines:
ListBox1.DataTextField = "text"
ListBox1.DataValueField = "value"
As shown in this sample:
Public Sub GetStatusCodeList()
Dim mobjListBoxData As New ListItemCollection
With mobjListBoxData
.Add(New ListItem("Select one...", "None"))
.Add(New ListItem("D - Deleted via Extract", "D"))
.Add(New ListItem("E - Deleted via WEB", "E"))
.Add(New ListItem("H - Hold", "E"))
.Add(New ListItem("R - SoftAuto", "R"))
End With
ListBox1.DataSource = mobjListBoxData
ListBox1.DataTextField = "text"
ListBox1.DataValueField = "value"
ListBox1.DataBind()
End Sub
This made it work on my machine.
Thank you, Mike
Microsoft, ASP.NET Support Professional
Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.
This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
> Thread-Topic: Problem with text and value properties for dropdownlist
bound control
> thread-index: AcOqCzyGb6AGz/zoRgOE4l39vecHxg==
> X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
> From: "=?Utf-8?B?Sm9yZ2U=?=" <>
> Subject: Problem with text and value properties for dropdownlist bound
control
> Date: Thu, 13 Nov 2003 09:26:13 -0800
> Lines: 43
> Message-ID: <7816CFA7-8CFD-46B8-B3F5->
> MIME-Version: 1.0
> Content-Type: text/plain;
> charset="Utf-8"
> Content-Transfer-Encoding: 7bit
> X-Newsreader: Microsoft CDO for Windows 2000
> Content-Class: urn:content-classes:message
> Importance: normal
> Priority: normal
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontro ls
> NNTP-Posting-Host: TK2MSFTCMTY1 10.40.1.180
> Path: cpmsftngxa06.phx.gbl!cpmsftngxa08.phx.gbl!cpmsftng xa10.phx.gbl
> Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontro ls:16149
> X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontro ls
>
> I have dropdownlist boxes that are bound to a function that loads them. I
set the text and value properties with different values as I want the
description and the return value to be different. When I select an item the
text and value properties are the same, why? example:
'************************************************* **************************
***********
'Load the Status Code Drop Down box
'************************************************* **************************
***********
Private Sub LoadStatusCodeDropDown()
drpStatusSel.DataSource = GetStatusCodeList()
drpStatusSel.DataBind()
End Sub
'************************************************* **************************
**************
'This function builds the items available for the Status dropdown boxe.
'************************************************* **************************
**************
Public Shared Function GetStatusCodeList() As ListItemCollection
Dim mobjListBoxData As New ListItemCollection()
With mobjListBoxData
.Add(New ListItem("Select one...", "None"))
.Add(New ListItem("D - Deleted via Extract", "D"))
.Add(New ListItem("E - Deleted via WEB", "E"))
.Add(New ListItem("H - Hold", "E"))
.Add(New ListItem("R - SoftAuto", "R"))
End With
Return mobjListBoxData
End Function
This code from the first item (0):
myString = drpStatusSel.SelectedItem.Value
is returning: "Select one..." instead of the word "None"
Thanks
>