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

问题描述

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

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

推荐答案

<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...



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

10-27 17:31