473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

listbox params in a Windows App vs Web App

CN
I have two fields in a database 1) Customer Name and 2)
Customer ID.

I know how to populate a listBox in a Web application so
it displays the Customer Names and passes the Customer ID
when you select a name.

I'm trying to do the same thing in a Windows Application,
but have only been able to bind the names to the control.

How do you attach the Customer ID value to the name?

In a Web application, I would just do:

Control.Items.Add(CustomerName);
Control.Items[i++].Value = (CustomerID);

Thanks!
Nov 15 '05 #1
2 1334
You can bind the listbox to a Datatable by setting the DataSource property.

Then set the DisplayMember property of the listbox to the appropriate column
name in the datatable (CustomerName), and set the ValueMember property to
the appropriate column (CustomerID).

-Darrin

"CN" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I have two fields in a database 1) Customer Name and 2)
Customer ID.

I know how to populate a listBox in a Web application so
it displays the Customer Names and passes the Customer ID
when you select a name.

I'm trying to do the same thing in a Windows Application,
but have only been able to bind the names to the control.

How do you attach the Customer ID value to the name?

In a Web application, I would just do:

Control.Items.Add(CustomerName);
Control.Items[i++].Value = (CustomerID);

Thanks!

Nov 15 '05 #2
*CN* tippselte am *19.10.2003 18:58* MESZ:
How do you attach the Customer ID value to the name?


Use the 'tag' property, like this:

///
ListViewItem itmX = new ListViewItem("CN");
itmX.Tag = "{764E8025-F9EE-40ab-850C-4E35C0F6FEE2}";
listView2.Items.Add(itmX);
\\\

HTH,

Michael

--
Michael Kremser
http://great.dynu.com/

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Luca | last post by:
Hello, I'm using a windows form in which there is a standard ListBox control. I want to add/remove objects from the ArrayList associated to the ListBox, and I want the ListBox immediately shows...
1
by: Patty O'Dors | last post by:
Hi I have some code to create an ownerdrawn listbox (derived), and when I add an item to it, the bold text of the first item (the title, 'Collections and Maturities') mysteriously seems to get...
2
by: xzzy | last post by:
I have an app that uses a listbox to display program status messages, and a public function to be used by the solution to update the listbox. I do not know how to make the listbox public so it...
7
by: Grant Schenck | last post by:
Hello, I have a ListBox control on a form. I add members of a class to the Items collection. They show up and I can select them. The text shown is from my classes ToString override. Now,...
8
by: Oddball | last post by:
Ok - I have a ListBox control and I'm ready to write my own DrawItem event handler. What I want to draw as the item is another control. I have created a user control that I would like to list in...
1
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
5
by: Dave H | last post by:
I have an asp:listbox, allowing multiple selections, is there a quick check to see if there's more than one selected, or do I need to go through the whole list? Thanks, Dave
10
by: Mr Newbie | last post by:
DropDown lists and Listboxes do not appear in the list of controls and values passed back to the server on PostBack in Request.Form object. Can someone confirm this to be correct and possibly...
3
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.