Hi,
I have a grid where I am dynamically creating all of my columns because I do not know the columns that will be returned at design time. I also want to add a Total column at the end that is going to summarize the particular month range the user has selected. My column is created correctly if I hardcode the months (see commented line below); however, if I try to build a similar string and pass that in the datafields, I get the error "Telerik.Web.UI.GridException: DataField "JAN10","FEB10","MAR10","APR10","MAY10","JUN10" for GridCalculatedColumn "Total" does not exist in current DataSource.". You can see from the error message that my string is in the correct format. I have seen posts on the forum regarding similar issues and it said that it was fixed in the latest release, but mine is still failing. I am using 10.2.
Thanks,
Tami
private
void
CreateCalcColumn(GridTableView oTableView,
string
sMonths)
{
GridCalculatedColumn totalColumn;
totalColumn =
new
GridCalculatedColumn();
oTableView.Columns.Add(totalColumn);
totalColumn.UniqueName =
"Total"
;
totalColumn.Expression =
"{0}+{1}"
;
totalColumn.DataType =
typeof
(
double
);
totalColumn.DataFields =
new
string
[] { lstMonths };
//totalColumn.DataFields = new string[] { "JAN10", "FEB10" };
totalColumn.Aggregate = Telerik.Web.UI.GridAggregateFunction.Sum;
totalColumn.HeaderText =
"Total"
;
totalColumn.HeaderStyle.CssClass =
"gridheader"
;
}