0

ただ知りたいだけです。2番目のグリッドビューで小計の総計を計算することはできますか?私が言いたいのは、それGridView2GridView1:にあるということです。

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

私は多くの解決策を試しましたが、それでもうまくいきませんでした。

4

2 に答える 2

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 に答える
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 に答える