protected void CustomersGridView_DataBound(Object sender, EventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
decimal rowTotal = Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "DC_No_Decimal"));
if (e.Row.DataItemIndex >= inderGrid.PageIndex * inderGrid.PageSize && e.Row.DataItemIndex < inderGrid.PageIndex * inderGrid.PageSize + inderGrid.PageSize)
{
grdTotal = grdTotal + rowTotal;
}
}
else if (e.Row.RowType == DataControlRowType.Footer && inderGrid.PageCount == inderGrid.PageIndex + 1)
{
for (int i = 0; i < inderGrid.Rows.Count; i++)
{
decimal currentRowCellVal = Convert.ToDecimal(inderGrid.Rows[i].Cells[3].Text);
grdTotal += currentRowCellVal;
}
e.Row.Cells[3].Text = grdTotal.ToString("c");
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "Totals:";
// for the Footer, display the running totals
e.Row.Cells[3].Text = grdTotal.ToString("0.00");
// e.Row.Cells[2].Text = quantityTotal.ToString("d");
e.Row.Cells[1].HorizontalAlign = e.Row.Cells[2].HorizontalAlign = HorizontalAlign.Right;
e.Row.Font.Bold = true;
}
}
此网格的目的是在网格的最终页面中显示总数。当我要去页页我得到一个错误:输入字符串格式不正确
Input string was not in a correct format.
在网格的最后一页,我需要总所有页面的细胞的电网[3]
你的问题是不是在[正确的格式(http://tinyurl.com/so-hints)。闭幕......啊,顺便问一下,你的问题是什么? –
嗨拉杰,你可以更新你的问题,给我们更多的信息,问题在哪里,至少要问一个问题,不要只是把标题。 – Purplegoldfish
你能告诉我们抛出异常的行吗?或者如果你可以用提到的代码附上异常屏幕截图? –