i need to populate my dropdownlist with month and year values to getdate + 1 year. I also want them in text format so "January 2009 and not 1 2009. This is the code i have written to populate the values. how do i convert them to January from 1?
Public Sub Load_xxxx(ByRef DDL As System.Web.UI.WebControls.DropDownList) Try Dim i As Integer Dim j As Integer For i = Now.Year To Now.Year For j = Now.Month To Now.Month + 11 DDL.Items.Add((j.ToString) + " " + (i.ToString)) Next Next Catch ex As Exception ReportError(ex) End Try End Sub
If your just trying to convert the integer value to month name an easy way to do it would be just to create an array of strings containing the month names and use your j value as the index.
How about