网格视图总计 [英] Grid view Total

查看:49
本文介绍了网格视图总计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好先生
我想在页脚网格视图中总计[ALL COLUMN],请告诉简单的方法....

hello sir
i want take [ALL COLUMN ] total in footer grid view please tell easy way ....

推荐答案

嘿...

像这样创建网格视图

Hey ...

Create grid view like this

<asp:GridView ID="gv" runat="server" ShowFooter="true">
                    </asp:GridView>



然后像这样编写C#代码..



and write the c# code like..

protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        gv.RowDataBound += new GridViewRowEventHandler(gv_RowDataBound);
    }
    double sum = 0;
    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            sum += Convert.ToDouble(e.Row.Cells[0].Text);
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[0].Text = sum + "";
        }
    }


我认为这可能有助于解决您的问题...


i think may help to solve ur prob...


在此处检查在GridView的页脚中显示总计 [ ^ ]


这篇关于网格视图总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆