在repeater控件的外面有一个按钮,要实现点击这个按钮来重置repeater中的TextBox控件中的值为0
//
重置发货数量为0
protected void LinkButton1_Click( object sender, EventArgs e)
{
Repeater rpt = form1.FindControl( " rpt_ReturnOrder " ) as Repeater;
foreach (RepeaterItem itm in rpt.Items)
{
TextBox txb_num = itm.FindControl( " txt_OutNum " ) as TextBox;
txb_num.Text = " 0 " ;
}
}
protected void LinkButton1_Click( object sender, EventArgs e)
{
Repeater rpt = form1.FindControl( " rpt_ReturnOrder " ) as Repeater;
foreach (RepeaterItem itm in rpt.Items)
{
TextBox txb_num = itm.FindControl( " txt_OutNum " ) as TextBox;
txb_num.Text = " 0 " ;
}
}
我的做法:
1.先获取repeater控件
2.用RepeaterItem来遍历Repeater中的TextBox
3.设置其值为0
我能想到的就是这个方法了,不知道有无高人有更好更简单的方法呢,希望大家一起讨论下!