Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Populate DropDownList with IEnumerable

Posted on 2013-02-07
2
Medium Priority
?
511 Views
Last Modified: 2013-02-11
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?
0
Comment
Question by:gogetsome
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
Srinivasulu Muppala earned 2000 total points
ID: 38867337
DropdownList.Datasource = GetProducts();
DropdownList.TextField = "Desc";
DropdownList.ValueField = "ID";
DropdownList.DataBind();

it will take respective values.
0
 

Author Comment

by:gogetsome
ID: 38867830
Hello, thank you for your help!

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!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question