This is a migrated thread and some comments may be shown as answers.
NumberGroupSizes
3 Answers 28 Views
This is a migrated thread and some comments may be shown as answers.
Barnabas
Top achievements
Rank 1
Barnabas asked on 29 Oct 2009, 08:15 PM

We have a variety of user who want number fields formatted in ways that may not match the culture of the computer that they are using. After we perform this operation

var culture = new CultureInfo(1033); 
culture.NumberFormat.NumberGroupSizes = new[] {0}; 
System.Threading.Thread.CurrentThread.CurrentCulture = culture; 
System.Threading.Thread.CurrentThread.CurrentUICulture = culture; 



We receive this error. This is a number format that we have been using for 5 years. We have used it with a variety of web controls including the .NET DataGrid. Does anyone see what is going on here? Thanks for any input.

Server Error in '/ourApplication' Application.

NumberGroupSizes
Parameter name: Every element in the value array should be between one and nine, except for the last element, which can be zero.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: NumberGroupSizes
Parameter name: Every element in the value array should be between one and nine, except for the last element, which can be zero.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentException: NumberGroupSizes
Parameter name: Every element in the value array should be between one and nine, except for the last element, which can be zero.]
   System.Globalization.NumberFormatInfo.CheckGroupSize(String propName, Int32[] groupSize) +2749826
   System.Globalization.NumberFormatInfo.set_NumberGroupSizes(Int32[] value) +60
   Telerik.Web.UI.InputUtil.FormatDouble(Double value, NumberFormatSettings NumberFormat) +265
   Telerik.Web.UI.NumberFormat.Format(Nullable`1 num, NumberFormatSettings config) +59
   Telerik.Web.UI.RadNumericTextBox.AddAttributesToRender(HtmlTextWriter writer) +124
   Telerik.Web.UI.RadInputControl.RenderInputElements(HtmlTextWriter writer) +87
   Telerik.Web.UI.RadInputControl.RenderContents(HtmlTextWriter writer) +33
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
   Telerik.Web.UI.RadWebControl.Render(HtmlTextWriter writer) +83
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.WebControls.TableCell.RenderContents(HtmlTextWriter writer) +57
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.WebControls.Table.RenderContents(HtmlTextWriter writer) +206
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.WebControls.TableCell.RenderContents(HtmlTextWriter writer) +57
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
   Telerik.Web.UI.GridTHead.RenderContents(HtmlTextWriter writer) +621
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
   Telerik.Web.UI.GridMultiRowItem.Render(HtmlTextWriter writer) +209
   Telerik.Web.UI.GridTHead.Render(HtmlTextWriter writer) +5
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   Telerik.Web.UI.GridTable.RenderContents(HtmlTextWriter writer) +1803
   System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
   Telerik.Web.UI.GridTable.Render(HtmlTextWriter writer) +2026
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
   Telerik.Web.UI.GridTableViewBase.Render(HtmlTextWriter writer) +30
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
   Telerik.Web.UI.RadCompositeDataBoundControl.RenderContents(HtmlTextWriter writer) +17
   Telerik.Web.UI.RadGrid.RenderContents(HtmlTextWriter writer) +56
   Telerik.Web.UI.RadGrid.Render(HtmlTextWriter writer) +137
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   Telerik.Web.UI.ControlRenderer.Render(HtmlTextWriter writer) +84
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.UpdatePanel.RenderChildren(HtmlTextWriter writer) +234
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.UpdatePanel.Render(HtmlTextWriter writer) +34
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   Telerik.Web.UI.PreControlToAjaxify.Render(HtmlTextWriter writer) +112
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +163
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +594
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Page.Render(HtmlTextWriter writer) +29
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266


Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

3 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 30 Oct 2009, 09:47 AM
Hello Barnabas,

From the stack trace of the exception you get it seems that the setting you specified through the NumberFormat.NumberGroupSizes property of the culture is not valid and hence generates ArgumentException as explained here.

Follow the directions from the MSDN resource or define non-empty array for NumberGroupSizes to see whether this helps.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Barnabas
Top achievements
Rank 1
answered on 30 Oct 2009, 04:46 PM
Sebastian,

Thanks for the reply. If you look at the value that we are setting for NumberGroupSizes you can see that it is valid and it does comply with the MSDN documentation. In fact, if it wasn't valid, that code wouldn't run.

I have isolated the bug. (Thank you reflector. Also thank you Telerik for not obfuscating your code.) Here is the scenario that I encountered. I am using a RadGrid with the pager set to NextPrevNumericAndAdvanced. This renders a RadNumericTextBox, in the pager control. The RadNumericTextBox has its own NumberFormatSetting, instead of using the supplied .NET culture. NumberFormatSetting.GroupSize.get() has this line.

 return this.numericTextBox.Culture.NumberFormat.NumberGroupSizes[0]; 
 
This grabs just the first element of NumberFormat.NumberGroupSizes from the CultureInfo object. Now for all of the cultures in System.Globalization.CultureTypes.AllCultures this value is 3. (That's key. Remember that for later on.)

Now we move on to Telerik.Web.UI.InputUtil.FormatDouble(Double value, NumberFormatSettings NumberFormat). That's the last mention of Telerik in the stace trace for this error. Here is the troublesome code in that function.
int[] numArray = new int[50]; 
for (int i = 0; i < numArray.Length; i++) 
    numArray[i] = NumberFormat.GroupSizes; 
provider.NumberFormat.NumberGroupSizes = numArray; 
 
The NumberFormat.GroupSizes that is sent into this function is one integer value. (For any non-custom culture this value will be 3.) What this piece of code does is just replicate that one integer value 50 times and then feed that array into NumberFormat.NumberGroupSizes.

Here is the net effect:
The most common values for NumberGroupSizes at the beginning of this process are:
{3}
{3,0}
{3,2}
For each of these values, here is what NumberGroupSizes would be at the end of the process:
{3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}
Those are not the same thing. But fortunately, most of the time, it wouldn't matter. The net effect is just casting all the instances of {3,2} and {3,0} to {3}.

Now lets look at the custom culture I am using. NumberGroupSize has a value of {0}. That is perfectly valid. The problem is that only the last element of the array can be 0. In my array the first, last and only element is 0. But here is what happens when this value travels the above code path. My NumberGroupSize is changed from {0} to  {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}. Only the last element of NumberGroupSize may be 0.

That is how the error condition below is generated.

My current workaround will be to use a template for my pager control.

Please let me know when this bug is fixed. I would love to be able use the build in pager control. One of the beautiful things about the RadGrid is that so much is built in. I have much less code to maintain. Thanks so much for all of the great work.



0
Nikolay Rusev
Telerik team
answered on 04 Nov 2009, 03:33 PM
Hello Barnabas,

I have already forward your comments on RadInputControl functionality. They will review your case and all the suggestions in your post and of course will investigate in details what's the best way of changing RadInput functionality.

I will update this thread whenever any change is made to RadInputControl.

Sincerely yours,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Barnabas
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Barnabas
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or