I need to convert a select list (which is populated by a data feed) into lower case, I have traced as far some code in the relevant controller;
private SelectList getAddres开发者_开发问答sCountriesListDD()
{
var addressCountries = myOPG.AddressCountries;
return new SelectList(addressCountries, "key", "value", "GBR");
}
The myopg part is the datafeed, I need to get the selectlist into lowercase.
How can I accomplish this?
Replace
var addressCountries = myOPG.AddressCountries;
with
var addressCountries = myOPG.AddressCountries
.Select(c => c.ToString().ToLowerInvariant());
if addressCountries is a list of strings, then something like this (using LINQ).....
var lcase = from c in addressCountries
select c.ToLower();
精彩评论