title: Using foreach loop with DataList on Page Load
body: <p>I am working with a datalist on one of my pages, while trying to find the controls using a foreach loop it does not go into the loop.</p>
  
  <pre><code>protected void Page_Load(object sender, System.EventArgs e)
  {
      if (!IsPostBack)
      {
          foreach (DataListItem dli in shoplistview.Items)
          {
              string productID = ((Label)dli.FindControl("lblProductID")).Text;
          }
      }
  }
  </code></pre>
  
  <p>Is the datalist not in the current runtime when !IsPostBack? Or is there something I am missing here? If you need any additional info I can try to include it. I appreciate any advice you can offer to me. Thank you for your time.</p>