Quercus Posted February 10, 2004 Posted February 10, 2004 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? Quote
mocella Posted February 11, 2004 Posted February 11, 2004 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. Quote
Denaes Posted February 11, 2004 Posted February 11, 2004 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 Quote
Tamer_Ahmed Posted February 14, 2004 Posted February 14, 2004 i think the best way is using list view it will allow u to view many fields in one listbox Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.