473,506 Members | 16,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

databound DropDownList columns?

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
2 1705
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1171
by: ASP Developer | last post by:
I created a very simple user control that has one dropdownlist. I bind the dropdownlist to database results on load in an ascx file. I would like to do be able to change the selectedindex from...
0
2249
by: Tand35006 | last post by:
Hi, I hope some one can help with this. I have a basic webform with 2 DropDownLists and a single DataGrid. What I am trying to do is populate the first DDList from a dataset on Form_Load. I then...
9
13892
by: Jakob Lithner | last post by:
1) I have a DataGridView with edit capability. But in some columns I want to limit the input with a DropDownList. There is no inbuilt column for DropDownLists so I intended to add one myself. I...
1
2019
by: DJ | last post by:
I have a DropDownList in Visual Web Developer that is databound to a SQL Database. Whenever the web page is opened the DropDownList is automatically filled with the first item in the table. My...
5
25291
by: maurban | last post by:
Hi there experts, I have a gridview with a couple textboxes and a dropdownlist. I'm trying to insert a default value into my database driven dropdownlist. I'm doing this in the rowdatabound...
0
1658
by: Mark Micallef | last post by:
Hi, I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm using: <InsertItemTemplate> <div class="insertArea">...
1
2595
by: Mark Micallef | last post by:
Hi, this question relates to a control in the Ajax toolkit for asp.net 2. I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm...
2
1664
by: Cirene | last post by:
In my databound datagrid i have a databound dropdownlist, like this: <asp:DropDownList ID="ddlAvail0" runat="server" SelectedValue='<%# Bind("AvailMon") %>'> <asp:ListItem></asp:ListItem>...
5
26613
by: nzkks | last post by:
Hi I am using these: ASP.Net 2.0, VB.Net, Visual Studio 2005, SQL Server 2005, Formview controls In a ASP.Net form I have 20 textboxes and 20 dropdownlists(ddl). All ddl(s) are databound and get...
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7307
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.