In this article I have explained how to populate dynamic month names in DropDownList in ASP.Net.
This article also explains how to add leading zeros to single digit so that it appears as 01, 02….09 when populated in ASP.Net DropDownList.
 
 
HTML Markup
The following HTML Markup consists of two DropDownLists and a Button.
Month Names: <asp:DropDownList ID = "ddlMonthNames" runat="server">
</asp:DropDownList>
<br /><br />
    Months: <asp:DropDownList ID = "ddlMonths" runat="server">
</asp:DropDownList>
<br /><br />
<asp:Button ID="Button1" Text="Submit" OnClick = "Submit" runat="server" />
 
 
Namespaces
You will need to import the following namespace.
C#
using System.Globalization;
 
VB.Net
Imports System.Globalization
 
 
Populating the DropDownList with Month Names in ASP.Net
Both the DropDownLists are populated in Page Load event, the first one is populated with Month names using the DateTimeFormatInfo GetMonthName method which gets the name of Month based on current culture.
The second DropDownList is simply populated with Months and for single digit months 1-9, leading zero is padded to it so that it appears as 01, 02….09.
On the click of the Button the Selected Texts and Values of both DropDownLists are displayed using JavaScript alert message box.
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!this.IsPostBack)
    {
        for (int month = 1; month <= 12; month++)
        {
            string monthName = DateTimeFormatInfo.CurrentInfo.GetMonthName(month);
            ddlMonthNames.Items.Add(new ListItem(monthName, month.ToString().PadLeft(2, '0')));
        }
 
        for (int month = 1; month <= 12; month++)
        {
            ddlMonths.Items.Add(new ListItem(month.ToString().PadLeft(2, '0'), month.ToString().PadLeft(2, '0')));
        }
    }
}
 
protected void Submit(object sender, EventArgs e)
{
    string message = "DropDown1: " + ddlMonthNames.SelectedItem.Text + " " + ddlMonthNames.SelectedItem.Value + "\\n";
    message += "DropDow21: " + ddlMonths.SelectedItem.Text + " " + ddlMonths.SelectedItem.Value;
    ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('" + message + "')", true);
}
 
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    If Not Me.IsPostBack Then
        For month As Integer = 1 To 12
            Dim monthName As String = DateTimeFormatInfo.CurrentInfo.GetMonthName(month)
            ddlMonthNames.Items.Add(New ListItem(monthName, month.ToString().PadLeft(2, "0")))
        Next
 
        For month As Integer = 1 To 12
            ddlMonths.Items.Add(New ListItem(month.ToString().PadLeft(2, "0"), month.ToString().PadLeft(2, "0")))
        Next
    End If
End Sub
 
Protected Sub Submit(sender As Object, e As EventArgs)
    Dim message As String = "DropDown1: " + ddlMonthNames.SelectedItem.Text + " " + ddlMonthNames.SelectedItem.Value + "\n"
    message += "DropDow21: " + ddlMonths.SelectedItem.Text + " " + ddlMonths.SelectedItem.Value
    ClientScript.RegisterClientScriptBlock(Me.[GetType](), "alert", (Convert.ToString("alert('") & message) + "')", True)
End Sub
 
Populate dynamic month names in ASP.Net DropDownList
 
Demo
 
Downloads