<asp:Repeater ID="repProductList" runat="server" OnItemDataBound="repProductList_ItemDataBound"> 
      <ItemTemplate> 
          <div class="productBuy"> 
              <span> 
                <label> 
                    <asp:TextBox ID="txtQuantity" MaxLength="2" runat="server" Width="30px"> </asp:TextBox> 
                </label> 
              </span> 
          </div> 
        </ItemTemplate> 
</asp:Repeater> ID="txtQuantity" 的TextBox 是我放在页面 repeater 控件中用于接收数据的,  那我在后台 .cs 的repeater_ItemCommand() 事件中,如何访问到这个TextBox 的值 ??  要循环遍历repeater 去找TextBox 吗  ?  代码怎么写 ?  高手请赐教!!!!!所有在repeater 中的子控件都要怎么访问 ??????

解决方案 »

  1.   

    TextBox txtClassid=(TextBox)e.Item.FindControl("txtBox");
    string gr_id=txtClassid.Text;
      

  2.   

    protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    Repeater rpColumnNews = (Repeater)e.Item.FindControl("txtQuantity");
                }
            }rpColumnNews 就是你输入框里的值,在那个方法里面些你要执行的方法就可以 不用遍历,Repeater帮你做好这个遍历了 你就直接绑定值就可以了