title: How to bind datalist from code behind in asp.net
body: <p>I want to bind datalist from code behind in asp.net</p>
  
  <p>i am taking product id's from a list and selecting all products on their bases</p>
  
  <p>Following is my code:</p>
  
  <pre><code>List&lt;string&gt; r_items_grid = (List&lt;string&gt;)Session["recent_items"];
  
  for(int i=0; i &lt; r_items_grid.Count; i++)
  {
  
      OleDbCommand cmd_r_items= new OleDbCommand("SELECT product_id,product_name,product_price,product_image_1 from products where product_id="+ Convert.ToInt32( r_items_grid[i]),con); 
      r_items_reader=cmd_r_items.ExecuteReader();
  
      DataList3.DataSource = r_items_reader;
      DataList3.DataBind(); 
  }
  </code></pre>
  
  <p>But i am only seeing last record in datalist</p>