Showing posts with label .net. Show all posts
Showing posts with label .net. Show all posts

Sunday, April 17, 2011

A mystery solved

Today, I was trying to solve a problem where on our French site, a specification number (which is a decimal number) of the same product  was toggling between 1.3 and 1,3 intermittently.  It should be 1,3 for French.  It turned out the problem was in two folds.

First of all, the following code is being used to convert decimal to string:
//specNumber = 1.3;

Secondly, the app is running on two load balanced servers.  One server's region and language is set up as:

 while the other is set up as below:

That explains why the value is appearing as 1.3 or 1,3 intermittently.

To address this problem, we need to fix it in code.  When the site is being browsed in French we'll use:

   var fr = CultureInfo.CreateSpecificCulture("fr-CA");

That way, the code is not dependent on the server region and language settings.

Thursday, July 23, 2009

Populating controls in FormView Insert or Empty empty template with default values

FormView doesn't make it easy for a developer when he wants to populate the controls in a empty or insert template with default values.  After doing some search, I found out one way to accomplish this is to override ItemCreated event as follows:

        protected void fvMine_ItemCreated(object sender, EventArgs e)
//if the current mode in insert mode
              if (fvMine.CurrentMode == FormViewMode.Insert)
//get a reference to the control
                            txt = (TextBox) fvMine.Row.FindControl("txtCity");
                            if (txt != null)
// populate it with a default value
                                txt.Text = "New York";

About Cullen

My photo
Christian, Father, Software Developer/Architect who enjoys technology and using it to make people's lives easier!