我需要一些东西向我的 GridView 添加一个累计总计列
i need something add a cumulative total column to my GridView
当我尝试该代码时出现了很多错误,我需要向我的 GridView 添加一个累计总计列,以显示行中数字列之一的累计总计。就像那样 Running / Cumulative total in GridView column 我需要的正是这里解决的问题,但代码无法正常工作
debit |credit |Total
2 | 0 | 2
0 | 1 | 3
-0.5 | 0 | 2.5
0 |1.5 |4
我的 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>
我的代码有错误
如果您尝试查找行类型等于页脚 (DataControlRowType.Footer) 的标签,您需要使用:
<asp:TemplateField>
<FooterTemplate>
<asp:Label ID="lblTotal" runat="server" Text=""></asp:Label>
</FooterTemplate>
</asp:TemplateField>
当我尝试该代码时出现了很多错误,我需要向我的 GridView 添加一个累计总计列,以显示行中数字列之一的累计总计。就像那样 Running / Cumulative total in GridView column 我需要的正是这里解决的问题,但代码无法正常工作
debit |credit |Total
2 | 0 | 2
0 | 1 | 3
-0.5 | 0 | 2.5
0 |1.5 |4
我的 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>
我的代码有错误
如果您尝试查找行类型等于页脚 (DataControlRowType.Footer) 的标签,您需要使用:
<asp:TemplateField>
<FooterTemplate>
<asp:Label ID="lblTotal" runat="server" Text=""></asp:Label>
</FooterTemplate>
</asp:TemplateField>