<script type="text/javascript"> $(function () { StatSum("lblAAcount", "spAAcount"); StatSum("lblBBcount", "spBBcount"); } function StatSum(lblId, spId) { var sum = 0; $("span[id$='" + lblId +"']").each(function () { sum += parseInt($(this).text()); }); $("#" + spId).text(sum); } </script> <asp:Repeater ID="rptTest" runat="server" > <HeaderTemplate> <table> <tr> <th>年度</th> <th>AA总人数</th> <th>BB总人数</th> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td><%#Eval("year")%></td> <td><asp:Label runat="server" ID="lblAAcount" Text='<%#Eval("AAcount")%>'></asp:Label></td> <td><asp:Label runat="server" ID="lblBBcount" Text='<%#Eval("BBcount")%>'></asp:Label></td> </tr> </ItemTemplate> <FooterTemplate> <tr> <td>合计</td> <td><span id="spAAcount"></span></td> <td><span id="spBBcount"></span></td> </tr> </table> </FooterTemplate> </asp:Repeater>