ASP.NET的gridview的页脚添加合计字段
2008-05-01 17:25
375 查看
转载于 “编程论坛”
int totalNumber, iNumber;
double totalMoney, iMoney;
protected void GRIDVIEW控件_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.EmptyDataRow)
{
DataRowView drvBasicCountInfor = (DataRowView)e.Row.DataItem;
iMoney = Convert.ToDouble(drvBasicCountInfor[6]);//6是第5列的数字
//生成总计
totalNumber += iNumber;
totalMoney += iMoney;
}
if (e.Row.RowType == DataControlRowType.Footer) //页脚
{
e.Row.Cells[5].Text = "总计金额";
e.Row.Cells[6].Text = string.Format("{0}", totalMoney);
}
}
别忘了 GridView控件showfooter的属性=true呀
int totalNumber, iNumber;
double totalMoney, iMoney;
protected void GRIDVIEW控件_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.EmptyDataRow)
{
DataRowView drvBasicCountInfor = (DataRowView)e.Row.DataItem;
iMoney = Convert.ToDouble(drvBasicCountInfor[6]);//6是第5列的数字
//生成总计
totalNumber += iNumber;
totalMoney += iMoney;
}
if (e.Row.RowType == DataControlRowType.Footer) //页脚
{
e.Row.Cells[5].Text = "总计金额";
e.Row.Cells[6].Text = string.Format("{0}", totalMoney);
}
}
别忘了 GridView控件showfooter的属性=true呀
相关文章推荐
- ASP.NET中为DataGrid添加合计字段
- ASP.NET中为DataGrid添加合计字段
- ASP.NET中为DataGrid添加合计字段
- ASP.NET中为DataGrid添加合计字段
- ASP.NET中为DataGrid添加合计字段
- GridView页脚添加合计字段的两种方法
- ASP.NET中为DataGrid添加合计字段
- ASP.NET中为DataGrid添加合计字段
- ASP.NET中为DataGrid添加合计字段
- ASP.NET中为DataGrid添加合计字段
- ASP.NET MVC 5 - 给电影表和模型添加新字段
- ASP.NET MVC 5 学习教程:数据迁移之添加字段
- ASP.NET中GridView字段类型
- Asp.net GridView添加删除确认和自动编号代码
- asp.net: GridView相关技术(五--模板列绑定字段过长的解决方案)
- asp.net学习笔记 在GridView中添加链接
- 在ASP.NET 2.0中操作数据之四十九:为GridView控件添加RadioButton
- 在ASP.NET 2.0中操作数据之六十四:GridView批量添加数据
- Asp.Net 中的GridView 添加行单击事件
- asp.net动态添加GridView的模板列,并获取列值