Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

select distinct using LINQ and bound to a dropdown list with id and display name

$
0
0

Hi,

On one of my sharepoint page, I want to populate dropdown list with countries, namely

<asp:DropDownList ID="ddlCountry" runat ="server"></asp:DropDownList>

In the code, I use LINQ:

 var country = (from p in dc.ProvCountries
                               select p.country_code ).Distinct();

            ddlCountry.DataSource = country;
                ddlCountry.DataBind();

I want the country_code to be  the ID, while the country_name will be the display name in the dropdown, how can that be done?

Thanks in advance.


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>