I'm trying to populate Month and Year in asp.net mvc project's cshtml view page
this is the view page code
@model IEnumerable<project.Models.ProductStatistics>
@{
}
@Html.DropDownList("ExpirationMonth", ExpirationMonthDropdown)
@Html.DropDownList("ExpirationYear", ExpirationYearDropdown)
this is the model
public class ProductStatistics
{
public IEnumerable<SelectListItem> ExpirationMonthDropdown
{
get
{
return Enumerable.Range(1, 12).Select(x =>
new SelectListItem()
{
Text = CultureInfo.CurrentCulture.DateTimeFormat.AbbreviatedMonthNames[x - 1] + " (" + x + ")",
Value = x.ToString(),
Selected = (x == Model.ExpirationMonth)
});
}
}
public IEnumerable<SelectListItem> ExpirationYearDropdown
{
get
{
return Enumerable.Range(DateTime.Today.Year, 20).Select(x =>
new SelectListItem()
{
Text = x.ToString(),
Value = x.ToString(),
Selected = (x == Model.ExpirationYear)
});
}
}
}
but here I'm getting following error in Model Class
The name 'Model' does not exist in the current context
also getting this error in view page
The name 'ExpirationMonthDropdown' does not exist in the current context