Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

If I have a list box data bound to a dataset, how can I get it to display more than one field from the dataset? Specifically, my dataset is names and addresses. I want the list box to show:

 

Holmes, Sherlock

Friday, Joe

Malloy, Pete

Bond, James

 

Can I do this with a databound list or do I need another approach?

Posted

You could try adding another column to that datatable and combine the FirstName and LastName fields into that column and then use that as your display member.

 

I tried a quick test where I tried something like:

cboTest.DataMember = dsTest.Tables[0].Columns[0].ToString() + "," + dsTest.Tables[0].Columns[1].ToString()

 

but that bombed.

Posted

for something similar, I'm using the C1 componant "Classic Flexgrid"

 

It allows you to have column or row headers if you wish, choose as many columns as you want and keep your data seperate.

 

If you're just displaying, then concatonating the informationg like shown in the above post is perfect.

 

If you're going to let someone select the data, you either have to go on the index (fat chance if you're sorting the data) or a search based on the item's text.

 

Two items, like first and last name seperated by a comma are easy to extract the first and last name for a search.

 

If you have more information (like I do), its easier to just give each item its own column so you can sort by any of the items (first name, last name, ID#, address, zip code, time, etc) at any time, on the fly.

 

Displaying non-unique data (like names) in a sorted list has always been a headache of mine when trying to keep it attached to other data. Aside from creating arrays of unique objects, the flex grid is the best option I've seen, right next to the Datagrid if you have the proper input (database/xml/dataset).

 

Good Luck

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...