日期:2014-05-17 浏览次数:20543 次
<asp:repeater runat="server" ID="rplunch" OnItemCommand="rplunch_ItemCommand">
<itemtemplate>
<li>
<asp:Label runat="server" ID="type" Text='<%#Eval("rmenuTypeName") %>'></asp:Label>
<asp:TextBox runat="server" ID="num"/>份
</li>
</itemtemplate>
</asp:repeater>
protected void rplunch_ItemCommand(object source, RepeaterCommandEventArgs e)
{
foreach (RepeaterItem item in rplunch.Items)
{
TextBox txtnum = (TextBox)item.FindControl("num");
s += txtnum.Text;
}
}
//button click:
int sum = 0;
foreach (RepeaterItem item in rplunch.Items)
{
TextBox txtnum = (TextBox)item.FindControl("num");
sum += int.Parse(txtnum.Text);
}
Response.Write(sum);