Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Problem with text and value properties for dropdownlist bound control

Reply
Thread Tools

Problem with text and value properties for dropdownlist bound control

 
 
Jorge
Guest
Posts: n/a
 
      11-13-2003
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 bo
'************************************************* ************************************
Private Sub LoadStatusCodeDropDown(

drpStatusSel.DataSource = GetStatusCodeList(
drpStatusSel.DataBind(

End Su

'************************************************* ***************************************
'This function builds the items available for the Status dropdown boxe
'************************************************* ***************************************
Public Shared Function GetStatusCodeList() As ListItemCollectio

Dim mobjListBoxData As New ListItemCollection(

With mobjListBoxDat

.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 Wit

Return mobjListBoxDat

End Functio

This code from the first item (0)

myString = drpStatusSel.SelectedItem.Valu

is returning: "Select one..." instead of the word "None

Thank

 
Reply With Quote
 
 
 
 
Mike Moore [MSFT]
Guest
Posts: n/a
 
      11-13-2003
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=?=" <(E-Mail Removed)>
> Subject: Problem with text and value properties for dropdownlist bound

control
> Date: Thu, 13 Nov 2003 09:26:13 -0800
> Lines: 43
> Message-ID: <(E-Mail Removed)>
> 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

>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lower bound & Upper bound sunil panda Java 9 10-07-2008 08:32 PM
Passing Bound Object value to another Bound Object Phillip Vong ASP .Net 0 07-27-2006 10:54 PM
How to represent the data in a not bound control via bound control Mario Krsnic ASP .Net 0 06-23-2006 07:38 AM
Bound dropdownlist in .NET 2.0 -- picking the selected value? anyeone ASP .Net Web Controls 6 12-21-2005 04:25 PM
Getting lower-bound and upper-bound of strings input Rhiner Dan C++ 1 03-27-2005 02:03 AM



Advertisments