将网格视图列总计添加到标签
本文关键字:添加 标签 网格 视图 | 更新日期: 2023-09-27 18:33:33
嗨,我正在尝试将行的数字添加到网格视图之外的标签中。 我该怎么做??
这是我的网格视图代码:
<asp:GridView ID="GridView1" runat="server" Width="539px" BackColor="White" BorderColor="#DEDFDE" BorderStyle="Double" OnRowDeleting="OnRowDeleting" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" Font-Size="Small" >
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Action" HeaderStyle-HorizontalAlign="Center" ShowHeader="False">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" runat="server" CausesValidation="False" CommandName="Delete" Height="22px" ImageUrl="~/images/dialog-close.png" onclientclick=" return confirm('Are you want to Delete this Item?');" Text="Delete" Width="22px" />
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FBFBF2" />
<SortedAscendingHeaderStyle BackColor="#848384" />
<SortedDescendingCellStyle BackColor="#EAEAD3" />
<SortedDescendingHeaderStyle BackColor="#575357" />
</asp:GridView>
以下是网格视图行:
dr["PartNumber"] = dtparts.Rows[i]["PartNumber"];
dr["Qty"] = qty;
dr["Price"] = priceff;
dr["ExtPrice"] = "$" + Convert.ToDouble(qty) * Convert.ToDouble(pricedb);
dttemp.Rows.Add(dr);
您可以在 RowDataBound 事件中对总计求和。 然后,取这笔款项并将其分配给您的标签。 看起来有几个这样的例子。.这是其一。