Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > databound DropDownList columns?

Reply
Thread Tools

databound DropDownList columns?

 
 
cider123@hotmail.com
Guest
Posts: n/a
 
      04-28-2006
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.



..

 
Reply With Quote
 
 
 
 
=?Utf-8?B?Y2xpY2tvbg==?=
Guest
Posts: n/a
 
      04-28-2006
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.
>
>
>
> ..
>
>

 
Reply With Quote
 
 
 
 
cider123@hotmail.com
Guest
Posts: n/a
 
      04-28-2006
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
embeding databound DropDownList in FormView spoils DropDownList ev Lagrange ASP .Net Web Controls 1 01-17-2009 08:31 AM
databound custom controls vs composite databound custom controls rodchar ASP .Net 0 11-26-2007 03:51 PM
templated databound control problem - not showing databound Manu ASP .Net Web Controls 0 05-22-2006 09:46 AM
Urgent help with ItemTemplate (datagrid) - databound DropDownList VB Programmer ASP .Net 6 09-01-2004 07:08 PM
Re: DataGrid with a template column which contains a databound dropdownlist jm ASP .Net 0 05-14-2004 10:22 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57