Just for educational purpose (as for myself as well :) ) I post this code.
Using this, a programmer can use a good practise, that is to use the culture information which is built in, into .NET instead of making that data him/herself.
based upon the following element in web.Config, the list will fill using the correct number of monthnames. It also keeps track of calendars, that have 13 months in some cultures.
<globalization uiCulture="nl-nl"/>
using System;
using System.Collections.Generic;
using System.Web;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
using System.Globalization;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int monthNumber = 0;
CultureInfo ci = Thread.CurrentThread.CurrentUICulture;
var myMonthnames = ci.DateTimeFormat.MonthNames
.Take(ci.Calendar.GetMonthsInYear(DateTime.Today.Year)).Select(p => new { monthNo = ++monthNumber, monthName = p });
ddlMonthnames.DataTextField = "monthName";
ddlMonthnames.DataValueField = "monthNo";
ddlMonthnames.DataSource = myMonthnames;
ddlMonthnames.DataBind();
}
}
<select name="ddlMonthnames" id="ddlMonthnames">
<option value="1">januari</option>
<option value="2">februari</option>
<option value="3">maart</option>
<option value="4">april</option>
<option value="5">mei</option>
<option value="6">juni</option>
<option value="7">juli</option>
<option value="8">augustus</option>
<option value="9">september</option>
<option value="10">oktober</option>
<option value="11">november</option>
<option value="12">december</option>
</select>