databound DropDownList columns?

Discussion in 'ASP .Net' started by cider123@hotmail.com, Apr 28, 2006.

  1. Guest

    I have a SqlDataSource bound to a DropDownList Combo. Works just fine.

    I noticed 2 properties you can set in the DropDownList, 1 for the value
    to be displayed in the "Text" column and 1 for the value to be used in
    the "Value" property.

    I'm at a catch 22 right now though..

    The SqlDataSource gets 2 field values.. "Name" and "Description".

    In the DropDownList I use field #1 and then I have a Label next to the
    DropDownList which displays field # 2

    Now when I click my [ Next ] Button I am storing the
    DropDownList.Text value in a "Profile". However, since I defined the
    "Value" attribute to use field # 2.. I get the value from field # 2.
    Working as intended.

    What I would like to do is get the value from field # 1 (Name) and move
    on, but I can't because of the way I have the databound setup.

    I've searched the internet for a while now and figured I'd post and ask
    for some help. I was hoping the "ListItem" for each entry was more
    like the ListViewItem where you could then read "subitem(xxx)" values.
    but no such luck.

    I have also run across some articles that mention using cached
    SqlDataSources? For the life of me, I couldn't find how to read the
    cached dataset.

    Another option talked about using a DataSet and binding it to the
    DropDownList? I might be missing something, but I couldn't find any
    articles or documentation on how to do that. The article talked about
    using events when the pointer moved or something--I'm so far out in
    left field on that one. I understand the concept, I just couldn't find
    anything on how to do it.

    Any help greatly appreciated.



    ..
    , Apr 28, 2006
    #1
    1. Advertising

  2. I'm not sure what you mean, you can get either the value or the text.

    DropDownList.SelectedItem.Text is the text
    DropDownList.SelectedValue or DropDownList.SelectedItem.Value contains the
    value.

    Usually this is used for key/value pairs.

    "" wrote:

    > I have a SqlDataSource bound to a DropDownList Combo. Works just fine.
    >
    > I noticed 2 properties you can set in the DropDownList, 1 for the value
    > to be displayed in the "Text" column and 1 for the value to be used in
    > the "Value" property.
    >
    > I'm at a catch 22 right now though..
    >
    > The SqlDataSource gets 2 field values.. "Name" and "Description".
    >
    > In the DropDownList I use field #1 and then I have a Label next to the
    > DropDownList which displays field # 2
    >
    > Now when I click my [ Next ] Button I am storing the
    > DropDownList.Text value in a "Profile". However, since I defined the
    > "Value" attribute to use field # 2.. I get the value from field # 2.
    > Working as intended.
    >
    > What I would like to do is get the value from field # 1 (Name) and move
    > on, but I can't because of the way I have the databound setup.
    >
    > I've searched the internet for a while now and figured I'd post and ask
    > for some help. I was hoping the "ListItem" for each entry was more
    > like the ListViewItem where you could then read "subitem(xxx)" values.
    > but no such luck.
    >
    > I have also run across some articles that mention using cached
    > SqlDataSources? For the life of me, I couldn't find how to read the
    > cached dataset.
    >
    > Another option talked about using a DataSet and binding it to the
    > DropDownList? I might be missing something, but I couldn't find any
    > articles or documentation on how to do that. The article talked about
    > using events when the pointer moved or something--I'm so far out in
    > left field on that one. I understand the concept, I just couldn't find
    > anything on how to do it.
    >
    > Any help greatly appreciated.
    >
    >
    >
    > ..
    >
    >
    =?Utf-8?B?Y2xpY2tvbg==?=, Apr 28, 2006
    #2
    1. Advertising

  3. Guest

    Eep. Seems to be a case of a brain misfire!

    I was under the delusion "SelectedItem" being the same as
    "SelectedValue". Coding so much stuff in the past I never recalled
    seeing those 2 paired together like that (probably something new in 2.0
    but maybe it existed in 1.1).. using intellisense to bang out
    "Selected" and then tabbing through once it looked right to me. It
    didn't register, for some reason at that time, that those were 2
    completely separate choices. ;)

    Just another crazy coder gone wild.. thanks for snapping me back
    inline. ;)
    , Apr 28, 2006
    #3
    1. Advertising

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. jm
    Replies:
    0
    Views:
    617
  2. VB Programmer
    Replies:
    6
    Views:
    553
    VB Programmer
    Sep 1, 2004
  3. rodchar
    Replies:
    0
    Views:
    377
    rodchar
    Nov 26, 2007
  4. Manu
    Replies:
    0
    Views:
    157
  5. Lagrange
    Replies:
    1
    Views:
    541
    Lagrange
    Jan 17, 2009
Loading...

Share This Page