Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Asp.Net Programming

Dropdown List - display value/actual id

Hi There,

I have recently started coding in asp.net (just 2 and a half days
now). I am writing a simple test app that gets data from a data base
and displays the value perfectly in the drop down list. However, each
display value is simply that - a display value and is pretty useless
to me further down the line unless I use the value as part of a select
to get the the key of the record. This would be inefficent so what I
would like to find out is if there is a way to immediately bind the
key value to the display value on the dropdown list object. This way,
when the value is selected, the user will see the display value but
behind the scene, I immediately have access to the key associated to
the display value. I have looked a a few options but none that I can
see will really help me over come my problem easily and I am sure that
there must be a way to bind the display value and the key to the same

I hope that I have explained myself correctly.


            Dim manufactureData As MANUFACTURER = New MANUFACTURER()
            Dim selectString as String()
            selectString = "SELECT MANUFACTURER WITH SUSPENDED #
            selectString &= " AND WITH MANUFACTURER_NAME # """""
            selectString &= " BY-DSND MANUFACTURER_NAME"
            While (manufactureData.nextRecord)
                If cmdManufacturer.Items.Count = 0 Then
                    cmdManufacturer.Items.Add("Please Select..")
                End If

            End While


Yes, the DropDownList supports setting both the text and the value, as in
the following example:

  <asp:DropDownList id="stateList2" runat="server">
    <asp:ListItem Selected="True" Value="" Text=""/>
    <asp:ListItem Value="Confusion" Text="Confusion"/>
    <asp:ListItem Value="Denial" Text="Denial"/>

To set this programatically, the Add method takes an overload allowing you
to pass in a ListItem object.

      Public Sub New(ByVal [text] As String, ByVal value As String)

Try the following:

    cmdManufacturer.Items.Add(New ListItem(manufactureData.MANUFACTURE_NAME,

Hope this helps,


<mervyntr@gmail.com> wrote in message


On Jun 6, 9:09 am, mervyntr@gmail.com wrote:

Hi Stevan,

This worked perfectly. Thank you very much for your help. Much


Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc