By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,351 Members | 1,239 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,351 IT Pros & Developers. It's quick & easy.

databound DropDownList columns?

P: n/a
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 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

"ci******@hotmail.com" 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.

..

Apr 28 '06 #2

P: n/a
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 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.