|
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Data;
namespace MvcBasic.Logic
{
/// <summary>
/// Defines the country entity.
/// </summary>
public partial class Country
{
/// <summary>
/// Get countries list ready to be used in UI.
/// </summary>
/// <param name="dataContext">The data context.</param>
public static List<SelectListItem> GetCountryList(MvcBasicSiteEntities dataContext)
{
List<SelectListItem> list = new List<SelectListItem>();
//
SelectListItem selectItem = new SelectListItem();
//
foreach (Country country in dataContext.Countries)
{
selectItem = new SelectListItem { Text = country.Name, Value = country.ID.ToString() };
//
list.Add(selectItem);
}
//
return list;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I have about 20 years experiences in leading software projects and teams and about 25 years of working experience in software development (SW Developer, SW Lead, SW Architect, SW PM, SW Manager/Group Leader).