出于某种原因,我的gridview的第一行没有添加到列的总和中。
此处的代码:
double total = 0;
foreach (GridViewRow gvr in GridView4.Rows)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string sNum = e.Row.Cells[6].Text;
double sum;
if (double.TryParse(sNum, out sum))
{
total += sum;
}
TextBox21.Text = total.ToString("c");
//GridView4.FooterRow.Cells[6].Text = total.ToString("c");
}
}