Last Updated: February 25, 2016
·
1.189K
· iondrimba

Quick DropDownList of days/range with LINQ

@{
    var days = Enumerable.Range(1, 31).Select(i => new SelectListItem
    {
        Text = i.ToString(),
        Value = i.ToString()
    });
    SelectList source= new SelectList(days, "Value", "Text");
}

@Html.DropDownList("listId",source, "select")