How to take total of dynamically created template columns in footer

2 posts, 1 answers
  1. Manish
    Manish avatar
    64 posts
    Member since:
    Jul 2011

    Posted 20 Dec 2012 Link to this post


    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;

  2. Answer
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Dec 2012 Link to this post


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

  3. DevCraft R3 2016 release webinar banner
Back to Top