Hi Colin, The error happens due to the fact that the value passed to the parse method is not a valid value (perhaps, it might be empty), you can easily see this thing when running your application in debug mode. In this case, there are a number of ways to do what you want: + You can use a BoundColumn for this number data, then use the sample code in your post to calculate the total value. + You can use a Literal control declared in the ItemTemplate of a TemplateColumn, the sample code to calculate the total value is something like this:
long total = 0;
for(int loop=0; loop<DataGrid1.Items.Count; loop++)
{
//'Literal1' is the id of the Literal control.
Literal lit = DataGrid1.Items[loop].FindControl("Literal1") as Literal;
total += long.Parse(lit.Text);
}
+ You create an event handler for the ItemDataBound event of the DataGrid column. In the event handler, you can get the number value with the help of the e.Item.DataItem property. Also, you should remember to check the ItemType to determine what row this code applies to as this method is called for every row of a datagrid control.