Reputation: 1472
I have a country list containing the Danish name and English name of the country.I need to Bind the English name from the list to a dropdownlist.
I tried something like
ddlCountry.Items.Clear();
ddlCountry.Items.Add(new ListItem("choose", ""));
var list = Country.GetCountryList();
ddlCountry.DataSource = list;
ddlCountry.DataBind();
But the dropdown only showing sting "Country".I need to show the name of the country.
My list is like below picture
Can any one help?
Upvotes: 0
Views: 108
Reputation: 53958
You could try this one:
var list = Country.GetCountryList().Select(x=>x.EnglishName);
This way using LINQ, you are selecting only the english name of the counrties that method called GetCountryList()
returns.
Upvotes: 1