Saturday, 21 May 2016
MVC - Fix the following error - The type or namespace name 'SelectListItem' could not be found (are you missing a using directive or an assembly reference?)
Watch this example on YouTube:
Error while executing the following code:
public IEnumerable<SelectListItem> Months
{
get
{
return DateTimeFormatInfo
.InvariantInfo
.MonthNames
.Select((monthName, index) => new SelectListItem
{
Value = (index + 1).ToString(),
Text = monthName
});
}
}
To fix it add the following using:
using System.Globalization;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment