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

SumFunction causing bind error when using Converter

1 Answer 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brian Graves
Top achievements
Rank 1
Brian Graves asked on 21 May 2010, 03:27 AM
Here's my code:

 

GridViewDataColumn colPI = new GridViewDataColumn();

 

colPI.DataType = columnType;

colPI.Header =

"PositionCalc";

 

colPI.DataFormatString = "{0:F2}";

colPI.IsVisible =

true;

 

colPI.UniqueName =

"PositionCalc";

 

colPI.DataMemberBinding =

new Binding("PositionCalc");

 

colPI.DataMemberBinding.Converter =

new CalculatingConverter();

 

colPI.DataMemberBinding.ConverterParameter =

"Position*Impressions";

 

 

var sumFunction = new SumFunction();

 

sumFunction.FunctionName =

"SumPosition";

 

sumFunction.SourceField =

"PositionCalc";

 

sumFunction.ResultFormatString =

"{0:F2}";

 

colPI.AggregateFunctions.Add(sumFunction);

_dg.Columns.Add(colPI);

If I comment out the 5 lines of code above my Add(), I don't get errors when I assign my data to _dg.ItemSource and my grid displays correctly (with the Footer summary for this column is missing).  However, when I try to add an aggregate function and my SourceField is set this column using the Converter, I get the following error during runtime:
Invalid property or field - 'PositionCalc' for type: Data

If I set my SourceField to a different column, it works fine.  Why can't I add an aggregate function for my Converter column?  Is there a different approach I can take?

1 Answer, 1 is accepted

Sort by
0
Accepted
Brian Graves
Top achievements
Rank 1
answered on 21 May 2010, 10:46 PM
Tags
GridView
Asked by
Brian Graves
Top achievements
Rank 1
Answers by
Brian Graves
Top achievements
Rank 1
Share this question
or