asp.net

Populate ASP.NET dropdown list with month names using LINQ

A
Desh-Duniya Team Author
| Published May 27, 2019
dropdownListMonth.Items.AddRange(
    Enumerable.Range(1, 12)
    .Select(x => new ListItem { 
        Text = new DateTimeFormatInfo().GetAbbreviatedMonthName(x), 
        Value = x.ToString() 
    }).ToArray());

Discussion (0)

Please sign in to participate in the discussion.
No comments yet. Be the first to join the conversation!