The way we usually do it, if the grid doesn't have a good sum function (I can't remember if GridView does or not), is to set the cell to an itemtemplate then call a method in the codebehind to stash the value in a dictionary and return the value again. Later in the footer, call a method to return the total value for the column.
Edit here's an example of some c# codebehind code:
public Dictionary<string, decimal> columnTotals;
public decimal saveValue(string colName, decimal cellValue)
{
columnTotals(colName) += cellValue;
return cellValue;
}
public decimal getColumnTotal(string colName)
{
return columnTotals(colName);
}
Then inside your grid call it via:
Data row item template code:
Hours cell: <%# saveValue("totalHours", Eval("TotalHours")).ToString() %>
Mins cell: <%# saveValue("totalMinutes", Eval("Minutes")).ToString() %>
Footer row item template code:
Hours cell: <%# ((int)getColumnTotal("totalHours")).ToString() %>
Mins cell: <%# ((int)getColumnTotal("totalMinutes")).ToString() %>
You can total as many columns as you like without needing to create separate public/global variables for each. Simply pass in unique column names to the saveValue method. We use it for totaling money columns frequently when the grid doesn't support it out of the box.
HTH -rog