GridView添加统计行 [转帖]
2008-12-18 19:29
204 查看
GridView添加统计(合计)行
前提:设置属性ShowFooter="True"
方法一:使用SQL查询统计出合计值,在绑定GridView时让其结果赋于一个DataTable(全局变量),然后在RowDataBound事件中
if (e.Row.RowType == DataControlRowType.Footer)
int mysum1 = 0;
int mysum2 = 0;
protected void GridList_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow )
DataRowView myrows=(DataRowView)e.Row.DataItem;
mysum1 +=Convert .ToInt32 (myrows[2].ToString ());
mysum2 += Convert.ToInt32(myrows[3].ToString());
}
// 合计
if (e.Row.RowType == DataControlRowType.Footer)
e.Row.Cells[0].Text = "合计";
e.Row.Cells[1].Text = mysum1.ToString();
e.Row.Cells[2].Text = mysum2.ToString();
}
}
转自:http://www.cnblogs.com/adam/archive/2007/03/30/694591.html
前提:设置属性ShowFooter="True"
方法一:使用SQL查询统计出合计值,在绑定GridView时让其结果赋于一个DataTable(全局变量),然后在RowDataBound事件中
if (e.Row.RowType == DataControlRowType.Footer)
int mysum1 = 0;
int mysum2 = 0;
protected void GridList_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow )
DataRowView myrows=(DataRowView)e.Row.DataItem;
mysum1 +=Convert .ToInt32 (myrows[2].ToString ());
mysum2 += Convert.ToInt32(myrows[3].ToString());
}
// 合计
if (e.Row.RowType == DataControlRowType.Footer)
e.Row.Cells[0].Text = "合计";
e.Row.Cells[1].Text = mysum1.ToString();
e.Row.Cells[2].Text = mysum2.ToString();
}
}
转自:http://www.cnblogs.com/adam/archive/2007/03/30/694591.html
相关文章推荐
- GridView添加统计(合计)行
- 在GridView中添加按钮后,如何触发按钮的各种事件? [转帖]
- GridView中添加最底层统计数据
- GridView添加统计(合计)行
- GridView添加统计(合计)行
- GridView添加统计(合计)行
- GridView添加统计(合计)行
- GridView添加统计(合计)行
- GridView添加统计(合计)行
- GridView添加统计(合计)行
- 在GridView中添加一行(新行) 如统计信息等
- C#中如何给GridView添加页脚以实现统计某一列值的和
- GridView添加统计(合计)行
- GridView添加统计(合计)行
- GridView添加统计(合计)行
- 如何在GridView中添加CheckBox控件列,添加删除确认对话框
- 为gridview添加删除提示。
- 为GridView添加鼠标事件
- 为GridView-Delete列添加确认对话框(2种方法)
- 博客园cnblogs添加访问统计:百度统计与Google Analytics 详细教程