Search:
Namespaces
Discussions
.NET v1.1
Feedback
Where does Combobox's Itemdata Property go?
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngcontrolscs' list
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Jigs
In VB6 it was really easy to load a
ComboBox
with data and then
use the ItemData property to associate a key value or something with the
item in the list.
There looks to no longer be an ItemData property... So,
how do you load manually (for example) Customer Names and Customer ID's into
a
ComboBox
-- showing the Customer Names but when one is selected, use the
Customer ID? Again, I want to do this manually and not use
DataBinding
.
-Jignesh
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
Reply to this message...
Brian Bilbro (VIP)
Here are two ways: In your .aspx (or .ascx) do the following:
<asp:ListBox id=3D"foobar" runat=3Dserver>
<asp:listitem value=3D"1" Text=3D"Item 1" />
<asp:listitem value=3D"2" Text=3D"Item 2" />
<asp:listitem value=3D"3" Text=3D"Item 3" />
<asp:listitem value=3D"4" Text=3D"Item 4" />
</asp:ListBox>
<select id=3D"foobar" runat=3Dserver>
<option value=3D"1">Item 1</option>
<option value=3D"2">Item 2</option>
<option value=3D"3">Item 3</option>
<option value=3D"4">Item 4</option>
</select>
if you are talking winforms, then you need to ask on one of the winforms =
lists:
http://www.aspfriends.com/aspfriends/winforms-cs.asp
Even though you said vb in the past, I'm assuming you mean C# since you =
sent the email to a C# list. However, if you ment vb.net then try:
http://www.aspfriends.com/aspfriends/winforms-vb.asp
for winforms
--
Brian
----- Original Message -----
From: Jigs <
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Mon, 5 Aug 2002 22:43:04 -0700 (PDT)
Subject: Where does Combobox's Itemdata Property go?
[Original message clipped]
Reply to this message...
Scott Watermasysk
You can also set this when you bind data to your listbox:
//foobar listbox
//Get some datatable/reader/dataset (mydata)with two columns: CustomerID, CustomerName
//Then:
foobar.DataSource = mydata;
foobar.DataValueField = "CustomerID";
foobar.DataTextField = "CustomerName";
foobar.DataBind();
No when you access the information on postback:
foobar.SelectedItem.Value will give you the selected CustomerID
foobar.SelectedItem.Text will give you the selected CustomerName
HTH,
Scott
---------- Original Message ----------------------------------
From: "Brian Bilbro" <
Click here to reveal e-mail address
>
Reply-To: "aspngcontrolscs" <
Click here to reveal e-mail address
>
Date: Tue, 6 Aug 2002 07:09:32 -0400
[Original message clipped]
Reply to this message...
System.Web.UI.DataBinding
System.Web.UI.WebControls.ListBox
System.Windows.Forms.ComboBox
System.Windows.Forms.ListBox
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com