title: ASP .NET - How to Iterate through a repeater?
body: <p>What I'm trying to do is iterate through a repeater and read some controls values:</p>
  
  <pre><code>   foreach (RepeaterItem iter in TablePanier.Items)
      {
          string guid = ((HiddenField)iter.FindControl("guid")).Value.ToString();
  
          // nombre exemplaires du livre
  
          int nbExemplaires = int.Parse(((System.Web.UI.WebControls.TextBox)iter.FindControl("txtNbExemplaires")).Text.ToString());
  
      }
  </code></pre>
  
  <p>As you can see, I have a HiddenValue and a TextBox. Unfortunately this isn't working, the values are not read correctly.</p>
  
  <p>What's wrong?</p>
  
  <p>Thank you!</p>
  
  <p><strong>EDIT:</strong>
  Here is the entire code of the form:</p>
  
  <pre><code>public partial class Panier : System.Web.UI.Page
  {
      Bussiness.Manager _manager = new Bussiness.Manager("MSSQLSERVER");
      IEnumerable&lt;Bussiness.iPanier&gt; _paniers;
      CurrencyConvertor _currencyConvertor = new CurrencyConvertor();
      Bussiness.iCommande _commande;
      int  idPanier;
  
      protected void Page_Load(object sender, EventArgs e)
      {
          if (Session["login"] != null)
          {
              Security security = new Security();
             _paniers = _manager.chargerPannierUtilisateur(Session["login"].ToString());
  
              foreach (Bussiness.iPanier p in _paniers)
              {
                  idPanier = p.id;
                  TablePanier.DataSource = p.Livres;
                  TablePanier.DataBind();
              }
          }
  
          else
          {
              Response.Redirect("~/Accueil.aspx");
          }
      }
      protected void btnCommande_Click(object sender, EventArgs e)
      {
  
  
          foreach (RepeaterItem iter in TablePanier.Items)
          {
              // id livre courant
              if (iter.ItemType == ListItemType.Item || iter.ItemType == ListItemType.AlternatingItem)
              {
                  string guid = ((HiddenField)iter.FindControl("guid")).Value.ToString();
                  int nbExemplaires = int.Parse(((System.Web.UI.WebControls.TextBox)iter.FindControl("txtNbExemplaires")).Text.ToString());
  
              }
          }
      }
  }
  </code></pre>
  
  <p>As you can see, the repeater is bound at the constructor level. And I'm trying to read the data when an event occur on a button of the page.</p>
  
  <p>Any idea ?</p>