This is a migrated thread and some comments may be shown as answers.

Calculated column can crash iis with stack overflow exception

1 Answer 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 10 Oct 2012, 03:14 PM
I've been working on a grid with a dynamic number of columns. One of the columns required a sum across columns with a total in a new calculated column. I implemented this and when the expressions for the miscalculation become too large (not very bit at all) it will crash iis with a stack overflow exception.

It's important to note I'm working around another bug where is one of the data values is null calculated expressions don't work.

So I was dynamically defining the expression for the calculated column like so:

for (int i = 0; i < dataColumns.Count; i++)
{
    expression += String.Format("({{{0}}} == null ? 0 : {{{0}}})+", IntFormatter.ToString(i));
}
expression = StringFormatter.Left(expression, expression.Length - 1);
ccol.Expression = expression;

When I have 10ish (or more) iterations of the above loop then I get the stack overflow exception from this:

//rebind
RadGridSearch.Rebind();

Removing the calculation allows this to work properly.

I'm reworking my implementation to do the calculation on the database side but thought I should mention this in case anyone else runs into this problem.

Our solution is using a slightly older build: Telerik.Web.UI_2011_2_712_Dev

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 15 Oct 2012, 01:11 PM
Hello James,

I am not sure why you are facing the issue, since I am unable to replicate it here. However you could try to use TemplateColumns and to do the calculations yourself on ItemDataBound event of the grid. You can find the cell for given column and assign it a value based on the rest cells in the same row.

Greetings,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or