Link to home
Start Free TrialLog in
Avatar of rafaelrgl
rafaelrgl

asked on

How to get months names

hi i build this function below to populate an dropdownlist:

        Dim dt As System.Globalization.DateTimeFormatInfo = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat
        Dim ditem As New ListItem
        ditem.Text = "Mês"
        ditem.Value = -1
        ditem.Selected = True
        ddl_mes.Items.Add(ditem)
        For t As Integer = 1 To 12
            Dim ditem2 As New ListItem
            ditem2.Text = dt.GetAbbreviatedMonthName(t)
            ditem2.Value = t
            ditem2.Selected = False
            ddl_mes.Items.Add(ditem2)
        Next

but the months are in english, and i want the months to be on the language that the user has choose on his computer or webbrowser.

any help?
Avatar of Bill Nolan
Bill Nolan
Flag of United States of America image

I think the problem lies in your instantiation of the DateTimeFormatInfo object.  I haven't looked it over enough to know just why, but I believe instantiating your own object will always create an English version.  There is a static method that uses the currently set culture:

ditem2.Text = System.Globalization.DateTimeFormatInfo.CurrentInfo.GetAbbreviatedMonthName(t);
Avatar of rafaelrgl
rafaelrgl

ASKER

sorry, did not work. any other suggestion?
ASKER CERTIFIED SOLUTION
Avatar of Bill Nolan
Bill Nolan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks