如何获得Repeater中所有Label的总和?

时间:2016-06-07 10:05:02

标签: asp.net

我想获得转发器内所有lblAUSD的总和,但不知道如何获得它。请帮助:)提前致谢。

是否有任何代码可以从Repeater计算总和,我在Gridview中有我的但不知道如何在转发器中执行此操作。

Gridview - This is the code behind from my GridView


Dim sum As Integer = 0
    For i As Integer = 0 To grvOperationalCost.Rows.Count - 1
        sum += Convert.ToDecimal(grvOperationalCost.Rows(i).Cells(2).Text)
    Next
    lblTotalCosts.Text = sum.ToString()

Repeater - This is the Item Template in my Repeater

<asp:Repeater ID="reptrData" runat="server" >
     <ItemTemplate>
         <div>
           <h6>Product Details</h6>
              <table style="width:100%">
                     <tr>
                         <td></td>
                         <td style="text-align :right">  <asp:Button ID="bttnViewPlattDetails" CommandName ="ViewPlatts" runat ="server" Text="View Platts"  /> &nbsp;<asp:Button ID="bttnRemove" runat ="server" Text="Remove" CommandName ="Remove" />
                         </td>
                     </tr>
                 </table>
             <asp:Panel ID="PanelHeader" runat="server" CssClass="ui-widget-header">

                 <table>
                     <tr>
                         <td><b>Product:</b></td> 
                         <td><asp:Label ID="lblProduct" runat ="server"><%#Eval("plCode")%></asp:Label><asp:Label Id="lblAProduct" runat ="server"  Text='<%#Eval("pHideCode")%>' visible="false" ></asp:Label> 
                         </td>
                        </tr>
                     <tr>
                         <td><b>Date:</b></td>
                         <td><asp:Label ID="lblDate" runat ="server"><%#Eval("plDate")%></asp:Label><asp:Label id="lblDate1" runat ="server" CssClass="frmdate" visible="false" Text='<%#Eval("pHideDate2")%>'></asp:Label> <asp:Label ID="lblDate2" runat ="server" CssClass="frmdate" visible="false" Text='<%#Eval("pHideDate2")%>' ></asp:Label>
                         </td>
                     </tr>
                    <tr>
                        <td><b>Average:</b></td>
                        <td><asp:Label ID="lblAverage" runat ="server"><%#Eval("plAverage")%></asp:Label></td>
                    </tr>
                     <tr>
                         <td><b>Net Purchase Price:</b></td>
                         <td><asp:Label ID="lblNetPurPrice" runat ="server"><%#Eval("plPurPrice")%></asp:Label></td>
                     </tr>

                </table> 

                 <table style="width:100%">
                     <tr>
                         <td></td>
                         <td style ="text-align:right "><b>USD:</b> &nbsp; <asp:Label ID="lblAUSD" runat ="server" DataFormatString="{0:#,###0.000}" Text='<%#Eval("plUSD")%>'></asp:Label> &nbsp; <b>AED:</b>  &nbsp; <asp:Label ID="lblAAED" runat ="server" DataFormatString="{0:#,###0.000}"><%#Eval("plAED")%></asp:Label></td>
                     </tr>
                 </table>
            </asp:Panel> 

               <asp:GridView ID="grvPlatts" runat ="server"></asp:GridView>
              <hr />                            
    </ItemTemplate> 

0 个答案:

没有答案