listbox params in a Windows App vs Web App

  • Thread starter Thread starter CN
  • Start date Start date
C

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!
 
*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
 
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
 
Back
Top