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?