首页 > 学院 > 开发设计 > 正文

简单随笔——如何在gridview的页脚显示信息。。。。

2019-11-14 16:51:24
字体:
来源:转载
供稿:网友

我是超级大菜鸟。。。哈哈 

先上图看看是不是你需要的

 

第一步,右击gridview,在事件中,单击RowdataBond事件。

在这之前一定要记得在gridview属性中的ShowFooter设置为“true”。

第二步,需要实现这个功能可以看看我的代码。

 1   PRotected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 2  3      { 4         if (e.Row.RowType == DataControlRowType.DataRow) 5          6          7         { 8             if (e.Row.RowIndex > -1) 9 10             {11              12                 sum1 += Convert.ToDouble(e.Row.Cells[4].Text);13                 sum2 += Convert.ToDouble(e.Row.Cells[5].Text);14                 sum3 += Convert.ToDouble(e.Row.Cells[6].Text);15 16             }17  18         }19         else if (e.Row.RowType == DataControlRowType.Footer)20         {21             e.Row.Cells[3].Text = "金额合计";22             e.Row.Cells[4].Text = sum1.ToString();23             e.Row.Cells[5].Text = sum2.ToString();24             e.Row.Cells[6].Text = sum3.ToString();25         }26 27     }
View Code

 

 

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表