databound DropDownList columns?

C

cider123

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.



..
 
G

Guest

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

cider123

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. ;)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top