gogetsome
asked on
Populate DropDownList with IEnumerable
Hello I need help with the following scenario...
Given a class called Product with a shared method GetProducts() that returns an IEnumerable collection of Product objects with the properties ID and Desc, how would you populate a drop down list?
Given a class called Product with a shared method GetProducts() that returns an IEnumerable collection of Product objects with the properties ID and Desc, how would you populate a drop down list?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have never worked with an IEnumerable collection of objects. From your post I gather it binds to the DDL just like any other call to get data like this for example:
Dim Products As IList = ProductManager.GetProducts
DropdownList.Datasource = Products
DropdownList.TextField = "Desc"
DropdownList.ValueField = "ID"
DropdownList.DataBind()
Thanks again!