我创建了一个非常简单的下拉框:
<asp:DropDownList ID="MonthDropDown" runat="server" AutoPostBack="True">
</asp:DropDownList>
代码背后:
MonthDropDown.DataSource = Enumerable.Range(1, 12);
MonthDropDown.SelectedIndex = DateTime.Now.Month;
MonthDropDown.DataBind();
有没有办法让MonthDropDown
(我的下拉框)显示月份的名称,而不是月份的数值。我想它可能是这样的
DateTimeFormatInfo.CurrentInfo.GetMonthName(MonthDropDown.SelectedIndex)?