GridView自动求和、求平均值小计[转]
2012-06-07 16:05
323 查看
转自清清月儿gridview72绝技,略有改动
前台:唯一的花头就是设置ShowFooter="True"
private double sum = 0;//取指定列的数据和,你要根据具体情况对待可能你要处理的是int
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
sum += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "dateTimeAll").ToString());
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[5].Text = "总薪水为:";
e.Row.Cells[6].Text = sum.ToString();
e.Row.Cells[3].Text = "平均薪水为:";
e.Row.Cells[4].Text = ((int)(sum / GridView1.Rows.Count)).ToString();
}
}
前台:唯一的花头就是设置ShowFooter="True"
private double sum = 0;//取指定列的数据和,你要根据具体情况对待可能你要处理的是int
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
sum += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "dateTimeAll").ToString());
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[5].Text = "总薪水为:";
e.Row.Cells[6].Text = sum.ToString();
e.Row.Cells[3].Text = "平均薪水为:";
e.Row.Cells[4].Text = ((int)(sum / GridView1.Rows.Count)).ToString();
}
}
相关文章推荐
- GridView加入自动求和求平均值小计
- GridView加入自动求和求平均值小计
- GridView加入自动求和求平均值小计?
- GridView自动求和、求平均值小计
- GridView加入自动求和求平均值小计
- GridView加入自动求和求平均值小计
- GridView加入自动求和求平均值小计[转]
- GridView加入自动求和求平均值小计
- GridView加入自动求和求平均值小计
- 17.GridView加入自动求和求平均值小计
- ALV自动排序求和小计
- EXCEL中对自动筛选的结果部分求和、平均值、最大、最小值等
- Gridview中加入求和和求平均值
- gridview自动求和及合并多列多行单元格
- Gridview中加入求和和求平均值 (转载)
- GridView 在Footer加上自动求和行
- GridView控件中自动求和、合并单元格和排序
- GridView 在Footer加上自动求和行
- ASP.NET2.0中给GridView动态添加模板列并自动绑定数据
- 怎样实现MindMapper中自动求和工具的运用