循环repeater中的每一列,并计算数据和

 <asp:Repeater ID="rpt" runat="server">

                                        <ItemTemplate>

                  <td><font color="red"><%# GetTotleCount(Eval("AdminName"), Eval("AdminId"))%></font></td>

                                                <asp:HiddenField ID="HiddenField1" runat="server"  Value='<%# GetTotleCount(Eval("AdminName"), Eval("AdminId"))%>'/>

                                        </ItemTemplate>

                                    </asp:Repeater>

 <tr>

                                        <td colspan="8" align="center">信息总计:<asp:Label ID="labeltotal" runat="server" Text=""></asp:Label></td>

</tr>







int s = 0;

        for (int i = 0; i < rpt.Items.Count; i++)

        {

            HiddenField hidd = (HiddenField)rpt.Items[i].FindControl("HiddenField1");

            s = s + int.Parse(hidd.Value);

        }

labeltotal.Text = s.ToString();

 

你可能感兴趣的:(循环)