当前位置: 代码迷 >> ASP.NET >> ASP中GridView中求汇总。该怎样?解决方案
  详细解决方案

ASP中GridView中求汇总。该怎样?解决方案

热度:4234   发布时间:2013-02-25 00:00:00.0
ASP中GridView中求汇总。。。该怎样????
应付费用   实付费用   其它费用    这是GridView中的三个字段。可以不在GridView   中增加一行用来显示汇总的钱数。我只要三个费用的总数就行!

------解决方案--------------------------------------------------------

protected void gvwInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
// 合计
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView myrows = (DataRowView)e.Row.DataItem;
num1 += Convert.ToInt32(myrows[2].ToString());
num2 += Convert.ToInt32(myrows[3].ToString());
num3 += Convert.ToInt32(myrows[4].ToString());
num4 += Convert.ToInt32(myrows[5].ToString());
num5 += Convert.ToInt32(myrows[6].ToString());
num6 += Convert.ToInt32(myrows[7].ToString());
num7 += Convert.ToInt32(myrows[8].ToString());
}
// 合计
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "合计 ";
e.Row.Cells[1].Text = @ " <asp:LinkButton ID= 'link1 ' OnClick= 'link1_Click ' runat= 'server '> "+num1.ToString()+ " </asp:LinkButton> ";
e.Row.Cells[2].Text = " <a href= 'htddtp://www.sohu.com ' > "+num2.ToString()+ " <a/> ";
e.Row.Cells[3].Text = num3.ToString();
e.Row.Cells[4].Text = num4.ToString();
e.Row.Cells[5].Text = num5.ToString();
e.Row.Cells[6].Text = num6.ToString();
e.Row.Cells[7].Text = num7.ToString();
}
}
  相关解决方案