簡體   English   中英

將GridView Column總計添加到標簽

[英]Add GridView Column grand total to label

嗨,我正在嘗試將行號添加到gridview之外的標簽中。 我該怎么做?

這是我的gridview代碼:

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

這是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事件中求和。 然后,取該總和並將其分配給您的標簽。 似乎有一些示例。 這是一個

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM