0

我只是想知道。是否可以在第二个网格视图中计算小计的总计?我的意思是GridView2GridView1

<asp:GridView ID="grdOne">
   <asp:Gridview ID="grdTwo">
      <---SubTotal--->
      <---Grand Total--->
   </asp:Gridview>
</asp:GridView>

因为我尝试了很多解决方案,但仍然没有奏效。

4

2 回答 2

0

您也可以参考以下链接:

http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/displaying-summary-information-in-the-gridview-s-footer-cs

于 2012-05-04T12:57:23.580 回答
0

我假设您在标签或文本中填写小计,或者您可以在绑定时访问它的值,所以您要做的就是像这样对我们 RowDataBound_Event:

public int sum = 0;

protected void GirdView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {   
        //Sum the value of each subtotal
        sum = sum + subTotalValue;

        //Access the control that you want to to set the GrandTotal in
    }
}

如果您仍然不明白,请详细告诉我您想要什么。

于 2012-05-04T12:05:39.317 回答