Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to get months names

Posted on 2011-10-03
4
Medium Priority
?
242 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:rafaelrgl
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Bill Nolan
ID: 36907113
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);
0
 
LVL 1

Author Comment

by:rafaelrgl
ID: 36913697
sorry, did not work. any other suggestion?
0
 
LVL 7

Accepted Solution

by:
Bill Nolan earned 2000 total points
ID: 36913702
I actually ran it myself; it works.

Perhaps you didn't properly set the culture?  I think you can do it either via Web.config, or programmatically (override Page.InitializeCulture, I believe).
0
 
LVL 1

Author Closing Comment

by:rafaelrgl
ID: 36939802
thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question