Use if IListSource for binding of combobox to the collection
Question posted by: amitjaura
(Newbie)
on
August 27th, 2008 10:15 AM
Now I am stuck at a point where I want to bind combobox with datasource.The coding I tried is:::::::::::::
BusLayer.Surgeon objsurgeon = new BusLayer.Surgeon();
BusLayer.SurgeonCollection surgeonCollection;
surgeonCollection = objsurgeon.GetSurgeonCollection();
cmbChiefSurgeon.DataSource = surgeonCollection.Collection(); cmbChiefSurgeon.ValueMember = "doctorName";
cmbAssistantSurgeon1.DisplayMember = "doctorName";
But in the bolded line it is showing error that we have to use IListSource..I know that it is an interface but don't know anything much about this...Please sort out this problem.........
3
Answers Posted
Please don't bump your threads so quickly.
Try to remember that this is an international forum and that the Experts are spread across several time zones. We expect you to bump your thread only once every 24 hours.
Bumping more often will take attention away from other members and is seen as selfish and rude.
MODERATOR
Well, if it wants you to use an IList object, i guess you have to either change your surgeon collection to be a list, or you have to create a new list, fill it with the items from the collection and use the list as the datasource, i suppose the second approach would require the least amount of work.
Ah, i found another approach, you declare a list and make it equal to your collection with the following code:
- collection.ToList<Type>()
again you would have to cast back before going to the DB.
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 197,034 network members.
|