Retrieving Values from a Multi Select List Box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a multi select list box that is bound to a datatable. I am trying to
retrieve the user's selections from the list box. I am using the code below.

foreach (System.Data.DataRowView item in lstServices.SelectedItems)
{
MessageBox.Show(item.ToString());
}

The message box displays System.Data.DataRowView. How do I get it to
display the actual value of the selected item - both the display value and
the bound value? Thanks for your help.

Weste
 
I solved my problem. I changed my code as follows and it worked

MessageBox.Show(item.Row.ItemArray[0].ToString()+ " - " +
item.Row.ItemArray[1].ToString());
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top