如题,要详细代码,谢谢

解决方案 »

  1.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)    {        if(e.Row.RowType   ==   DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.EmptyDataRow)             {                 DataRowView   drvBasicCountInfor   =   (DataRowView)e.Row.DataItem;                 iNumber   =   Convert.ToInt32(drvBasicCountInfor[7]);                 iMoney   =   Convert.ToInt32(drvBasicCountInfor[8]);             }                         //   生成总计          //totalNumber += iMemberNo;          //totalMoney += iVisitNo;          totalNumber += iNumber;          totalMoney += iMoney;                                if(e.Row.RowType   ==   DataControlRowType.Footer)             {                 e.Row.Cells[6].Text   =   "总计";              e.Row.Cells[7].Text = Convert.ToString(totalNumber-iNumber);              e.Row.Cells[8].Text = Convert.ToString(totalMoney-iMoney);             }     }
     
      

  2.   

    前台:
    <asp:GridView ID="GridView2" runat="server" 
    AutoGenerateColumns="False" 
    OnRowDataBound="GridView1_RowDataBound" 
    ShowFooter="true">
    <Columns>
    <asp:TemplateField>
    <ItemTemplate>
        <asp:Label ID="labelfirst" runat="server" Text='<%# Eval("first") %>'></asp:Label>
    </ItemTemplate>
    <FooterTemplate>
        <asp:Label id="labelAll" runat="server" Text="总计:"></asp:Label>
    </FooterTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>
    后台:
    private int num = 0;
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DataRowView dr = e.Row.DataItem as DataRowView;
            num += Convert.ToInt32(dr.Row["first"]);
        }
        else if (e.Row.RowType == DataControlRowType.Footer)
        {
           Label LabelAll =  e.Row.FindControl("labelAll") as Label;
           if (LabelAll != null)
           {
               LabelAll.Text += num.ToString();//"计算的总数,或者也可以单独计算";//
           }
        }
    }
    "first"是我数据源的一个字段
      

  3.   


    fxqyyzg(海冬青)(昨夜西风凋碧树。独上高楼,望尽天涯路) 
    正解 
      

  4.   

    if(e.Row.RowType   ==   DataControlRowType.Footer)主要就是这个!