Hi Comunidadmexi..,
Please refer below sample.
HTML
<div>
<asp:DropDownList runat="server" ID="ddlMonths">
<asp:ListItem Text="[ === Select month === ]" Value=""></asp:ListItem>
</asp:DropDownList>
</div>
Namespaces
C#
using System.Globalization;
VB.Net
Imports System.Globalization
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
var previousMonth = DateTime.Now.AddMonths(-1).Month;
ddlMonths.Items.Clear();
ddlMonths.Items.Insert(0, new ListItem { Text = "[ === Select month === ]", Value = "" });
ddlMonths.Items.Insert(1, new ListItem { Text = DateTimeFormatInfo.CurrentInfo.GetMonthName(previousMonth), Value = previousMonth.ToString() });
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim previousMonth = DateTime.Now.AddMonths(-1).Month
ddlMonths.Items.Clear()
ddlMonths.Items.Insert(0, New ListItem With {
.Text = "[ === Select month === ]",
.Value = ""
})
ddlMonths.Items.Insert(1, New ListItem With {
.Text = DateTimeFormatInfo.CurrentInfo.GetMonthName(previousMonth),
.Value = previousMonth.ToString()
})
End If
End Sub
Screenshot