Tuesday, February 8, 2011

How to populate a DropDownList with Culture-specific Month names

DateTimeFormatInfo.MonthNames is a useful property to fetch the culture-specific full names of the month. This property gets a string array containing the names of the month. Remember to add a reference to the System.Globalization namespace.

Here’s how to use this property and populate a DropDownList with month names:

string[] names = DateTimeFormatInfo.CurrentInfo.MonthNames;
DropDownList1.DataSource = names;
DropDownList1.DataBind();

No comments:

Post a Comment

Ajax CalendarExtender displaying at wrong position in Chrome

< script type ="text/javascript" language ="javascript">     function onCalendarShown(sender, args)...