Dropdown list control problem

Discussion in 'ASP .Net Web Controls' started by Jerry, Sep 29, 2004.

  1. Jerry

    Jerry Guest

    I have a dropdown list and I am linking it to a database
    table called "Product". The fields in the database are
    ProductID (PK), price, and description. I am assigning
    the description field from the DB to the text field (what
    gets displayed) in the dropdown. I am assigning the
    price from the DB to the Value in the dropdown list.


    Data:
    the second item in the list has a price of 10.00 and the
    fourth item in the list also has a price of 10.00. All
    of the other prices are different.

    Problem: When you click the fourth item the second item
    is displayed. So it appears that .NET is using the value
    field and displaying the first record it sees with that
    value rather than using the index of the dropdown list.
    This seems to me to be a .NET bug.

    Any ideas?

    Thanks,

    Jerry
     
    Jerry, Sep 29, 2004
    #1
    1. Advertisements

  2. You never get the index. DropDown list's property SelectedItemIndex gets set
    according to value field returned.

    You could either:
    1. inherit this control and appropriately set SelectedItemIndex acording to
    Value & Text

    2. It's actually strange to put something nonunique in the Value filed.
    Change the Value field or concat it with a unique value and split both
    values on the server to get the correct item index.

    --
    RobertK
    { Clever? No just smart. }

    "Jerry" <> wrote in message
    news:3dc801c4a663$b5765220$...
    > I have a dropdown list and I am linking it to a database
    > table called "Product". The fields in the database are
    > ProductID (PK), price, and description. I am assigning
    > the description field from the DB to the text field (what
    > gets displayed) in the dropdown. I am assigning the
    > price from the DB to the Value in the dropdown list.
    >
    >
    > Data:
    > the second item in the list has a price of 10.00 and the
    > fourth item in the list also has a price of 10.00. All
    > of the other prices are different.
    >
    > Problem: When you click the fourth item the second item
    > is displayed. So it appears that .NET is using the value
    > field and displaying the first record it sees with that
    > value rather than using the index of the dropdown list.
    > This seems to me to be a .NET bug.
    >
    > Any ideas?
    >
    > Thanks,
    >
    > Jerry
    >
    >
     
    Robert Koritnik, Sep 30, 2004
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manish
    Replies:
    0
    Views:
    354
    Manish
    Aug 12, 2003
  2. Iams
    Replies:
    1
    Views:
    431
    Wilco Bauwer
    Feb 17, 2005
  3. =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?=

    Dropdown List - Check if value exists in list prior to selection

    =?Utf-8?B?QnJlbmRlbiBCaXhsZXI=?=, Mar 10, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    2,214
    =?Utf-8?B?QnJlbmRlbg==?=
    Mar 20, 2007
  4. =?Utf-8?B?RGF2ZSBU?=

    Columns in Dropdown list and list box

    =?Utf-8?B?RGF2ZSBU?=, Jun 25, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    608
    jufemaiz: jc
    Jun 27, 2007
  5. mldardy
    Replies:
    1
    Views:
    899
    mldardy
    Dec 10, 2008
  6. M. Craig

    How to set background color of List item in dropdown list

    M. Craig, Nov 12, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    453
    M. Craig
    Nov 12, 2003
  7. M. Craig
    Replies:
    1
    Views:
    944
    Victor Garcia Aprea [MVP]
    Jan 9, 2004
  8. Bryan Stauffer

    Dropdown List doesn't know what's in it's list

    Bryan Stauffer, Jul 6, 2006, in forum: ASP .Net Web Controls
    Replies:
    6
    Views:
    252
Loading...