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

How to take total of dynamically created template columns in footer

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manish
Top achievements
Rank 2
Manish asked on 20 Dec 2012, 06:26 AM
Hi,

I want total of a column in footer but i am creating my columns dynamically and it is asp label type and i need Total of that column in footer

I am using this code. But it returning a error page with error

Sum is not supported for type "System.Object".

but when i comment line denoted with * than page works fine but not able to display total. Please help


  templateColumn = new GridTemplateColumn();
  controlID = "lbl_Total" + colCounter.ToString();
   templateColumn.ItemTemplate = new CreateItemTemplate("Label", this, controlID, null, 27, "16px", colCounter, dtSchedule.Rows.Count);
  templateColumn.HeaderText = dtGetColumnsNameForGrid.Rows[colCounter - 1]["HeaderText"].ToString();
  templateColumn.UniqueName = dtGetColumnsNameForGrid.Rows[colCounter - 1]["UniqueName"].ToString();
  templateColumn.DataField = dtGetColumnsNameForGrid.Rows[colCounter - 1]["UniqueName"].ToString();
 templateColumn.FooterText = "Total: ";
*****  templateColumn.Aggregate = GridAggregateFunction.Sum;



1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Dec 2012, 06:53 AM
Hi,

I am not quite sure about your issue. Make sure that you have defined the datatype for the column as shown below.
C#:
templateColumn.DataType = typeof(System.Int32);
templateColumn.Aggregate = GridAggregateFunction.Avg;

Thanks,
Princy.
Tags
Grid
Asked by
Manish
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or