locked
decimal with comma / datetime etc RRS feed

  • Question

  • User-975177758 posted

    Hi!

    I develop a small competiotion app for my golfclub where I have to use decimals for the handicap calculations.

    In web.config: <globalization culture="sv-SE" uiCulture="sv-SE"

    In my working computer I can work with swedish date and dot (.) as decimal separator - it will not accpt comma (,) as separator.

    But - on the server, the datetime work fine but the dot will not work - argh#¤%

    Tried to change the web.config to "en-US" but then the datetime colapsed and couldnt be saved into the mysql.

    Any idé ?

     

    Saturday, March 27, 2010 4:05 AM

Answers

  • User-1636183269 posted

    Hello,

    Just refer my post in below url, in US decimal seprator is "." and in german,italian is "," then if we apply in web.config then it will work for only single culture, prefer to create base page. Mark as answer if this thread helps you.

    http://forums.asp.net/t/1514920.aspx 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 31, 2010 11:27 PM

All replies

  • User-1636183269 posted

    Just refer first : http://forums.asp.net/t/1514920.aspx 

    //In web.config we set default date seprator, you can use . or \
                        //<add key ="DateSeparator" value ="."/>
                        objDateTimeFormatInfo.DateSeparator = ConfigurationManager.AppSettings["DateSeparator"].ToString();

     

    objCultureInfo.NumberFormat.NumberGroupSeparator = ".";
            objCultureInfo.NumberFormat.NumberDecimalSeparator = ",";
            objCultureInfo.NumberFormat.NumberGroupSeparator = ".";
            objCultureInfo.NumberFormat.CurrencyDecimalSeparator = ",";

    I think, now aleast you know what you have to do.
            objCultureInfo.NumberFormat.CurrencyGroupSeparator = "."

                        

    Saturday, March 27, 2010 9:47 PM
  • User-975177758 posted

    Hi!

    Thanks for Your reply - have seen Your refering post before! But it doesn´t work out. I´m not sure if there are any settings on the webserver.

    private int id;
    private string golfid;
    private string name;
    private decimal startHcp;
    private GameClass playerClass;
    private int gender;

    public Player() {}

    public Player(IDataReader r)
    {
    id = r.GetInt32(r.GetOrdinal("ID"));
    golfid = cms_domain.DataCon.util.getStringVal(r,"GolfID");
    name = cms_domain.DataCon.util.getStringVal(r,"Name");
    startHcp = r.GetDecimal(r.GetOrdinal("StartHcp"));
    gender = r.GetInt32(r.GetOrdinal("Gender"));
    playerClass = new GameClass(r.GetInt32(r.GetOrdinal("ClassID")),cms_domain.DataCon.util.getStringVal(r,"ClassName"));
    }


    This is a snip from my player class - and the decimal attribute startHcp will be decimalseparated with "," on the server but with "." on my computer. In the database it´s with "."

    I Want the "." as separator :)

    I tried this on the adminpage which use the class:

    protected override void InitializeCulture()
    {
    CultureInfo objCultureInfo = new CultureInfo("sv-SE");
    Thread.CurrentThread.CurrentUICulture = objCultureInfo;
    objCultureInfo.NumberFormat.NumberDecimalSeparator = ".";
    }

     Still "," as decimalsep.

    Must be some settings on the iis because I have the right datetime format ("yyyy-MM-dd") and "." as dec.sep.

     

    Sunday, March 28, 2010 4:11 AM
  • User-975177758 posted

    Any idéas anyone about the settings? In worst case I have to define a method to convert the decimalseparator each time!

    Tuesday, March 30, 2010 4:44 AM
  • User-1636183269 posted

    Just swap your statement and it is working fine.

    objCultureInfo.NumberFormat.NumberDecimalSeparator = ".";

    Thread.CurrentThread.CurrentUICulture = objCultureInfo;


    Tuesday, March 30, 2010 4:55 AM
  • User-975177758 posted

    Hi, and thanks for Your fast reply!


    I missed to even override: Thread.CurrentThread.CurrentCulture = objCultureInfo; Then it worked!!!!


    But - are there any convenient way to do this global? Web.config? Ord do I have to implement this culture overide for all pages where I will calculate with decimals ?


     

    Wednesday, March 31, 2010 7:10 AM
  • User-1636183269 posted

    Hello,

    Just refer my post in below url, in US decimal seprator is "." and in german,italian is "," then if we apply in web.config then it will work for only single culture, prefer to create base page. Mark as answer if this thread helps you.

    http://forums.asp.net/t/1514920.aspx 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, March 31, 2010 11:27 PM