2012-05-03 81 views
0

我只是想知道。是否有可能在第二個gridview中計算總計小計?我的意思是,GridView2GridView1是否有可能在第二個gridview中計算總計?

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

因爲我已經嘗試了許多解決方案,但它仍然沒有奏效。

+0

如果我的理解沒錯,小計爲第一格,並要顯示在第二個網格中的總計? –

+0

沒有。第二個網格中的小計和總計。 – stillLearning

回答

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

如果您還別沒有想法,請準確地告訴我你想要的東西。

相關問題