0

when i try that code is give me a lot of errors i need something add a cumulative total column to my GridView that would show a cumulative total of one of the numeric columns in the row. like that Running / Cumulative total in GridView column i need exactly what solved here but code is not working

 debit  |credit |Total         
 2      | 0     | 2
 0      | 1     | 3
-0.5    | 0     | 2.5
 0      |1.5    |4

the errors shown whem I tried to use the code in that question

that my html

        <asp:TemplateField HeaderText="amount">
            <ItemTemplate>
                <asp:Label runat="server" ID="lblTotal" Text=""></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>


         <asp:TemplateField HeaderText="debit">
            <ItemTemplate>
                <asp:Label ID="debit" runat="server" Text='<%# (Eval("stat_flag").ToString() =="d" ) ? Eval("stat_amount"): "0.00" %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>

              <asp:TemplateField HeaderText="credit">
            <ItemTemplate>
                <asp:Label ID="credit" runat="server" Text='<%# (Eval("stat_flag").ToString() =="c" ) ? Eval("stat_amount"): "0.00" %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>

that my code with the error enter image description here

Community
  • 1
  • 1
rawan
  • 27
  • 8

1 Answers1

0

If you try to find label with rowtype equal Footer (DataControlRowType.Footer), you need to use this:

<asp:TemplateField>
    <FooterTemplate>
        <asp:Label ID="lblTotal" runat="server" Text=""></asp:Label>
    </FooterTemplate>
</asp:TemplateField>