title: Select all images using ASP.NET
body: <p>I am new to ASP.NET and C#. I am trying to retrieve all images from folder and show it on page, but it's only selecting one image.</p>
  
  <p>My ASP.NET code:</p>
  
  <pre><code>&lt;form id="form1" runat="server" class="col-lg-5"&gt;            
      &lt;asp:Image ID="Image" runat="server" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My C# code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Data.SqlClient;
  using System.Data;
  using System.Configuration;
  
  namespace Blog
  {
      public partial class index : System.Web.UI.Page
      {
          SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["blogconnection"].ToString());
          protected void Page_Load(object sender, EventArgs e)
          {
              con.Open();
              string allimage;
              string qry="select * from images";
              SqlCommand cmd = new SqlCommand(qry, con);
              SqlDataReader dr =cmd.ExecuteReader();
  
              if (dr.HasRows)
              {
                  while(dr.Read())
                  {
                     if (!string.IsNullOrEmpty(Convert.ToString(dr["Image_Path"])))
                     {                                             
                          Image.ImageUrl = Convert.ToString(dr["Image_Path"]);                                         
                     }
                  }
             }
             con.Close();
         }               
      }
  }
  </code></pre>
  
  <p><strong>What I want:</strong>   I want to select all image which path is store in sql table.</p>
  
  <p><strong>Additional:</strong> is there a way to select videos from folder which path is store in sql, mean to select videos and images from different folder and show both on same page by date specified or by latest upload etc.</p>
  
  <p>Any help will be appreciated.</p>
  
  <p><strong>Edit #1</strong> </p>
  
  <p>In php i use the below code to get all images and show it, is there any thing equivalent to the below code in ASP.NET?</p>
  
  <p><em>PHP Code</em></p>
  
  <pre><code>&lt;?php
  include 'conn.php';
  $smt=$conn-&gt;prepare('SELECT * FROM post');
  $smt-&gt;execute();
  
  ?&gt;
  &lt;?php include 'header.php';
  
  ?&gt;
  &lt;div class=""&gt;
  &lt;?php
  if(isset($_SESSION['user']))
  {
  include 'nav.php';
  }
  else
  {
  include 'nav-simple.php';
  }
  ?&gt;
  &lt;?php include 'slider.php';?&gt;
  
  &lt;?php include 'right_sidebar.php';?&gt;
  
      &lt;div class="col-md-1 top_space"&gt;&lt;/div&gt;
  &lt;div class="container col-md-8 main-container-top"&gt;
  
  
      &lt;br/&gt;
  
  &lt;div class=""&gt;
      &lt;?php while ($gdata = $smt-&gt;fetch(PDO::FETCH_OBJ)): ?&gt;
          &lt;a href="#" class="col-md-4"&gt;&lt;img src="posts/&lt;?php echo $gdata-&gt;Post_Path; ?&gt;" alt="image" class="post-image"/&gt;&lt;/a&gt;
          &lt;div class="media-body col-md-8 post pull-left"&gt;
              &lt;div class="post-overview"&gt;
                  &lt;ul&gt;
                      &lt;li class="post-category"&gt;&lt;?php echo $gdata-&gt;Category; ?&gt;&lt;/li&gt;
                      &lt;li class="post-timestemp"&gt;Post on &lt;?php echo $gdata-&gt;Post_Date; ?&gt;&lt;/li&gt;
                  &lt;/ul&gt;
  
  
                  &lt;a href="post-description.php?id=&lt;?php echo $gdata-&gt;Id ?&gt;"&gt;&lt;h4
                          class="media-heading h4"&gt;&lt;?php echo $gdata-&gt;Title; ?&gt;&lt;/h4&gt;&lt;/a&gt;
  
                  &lt;p class="post-text"&gt;&lt;?php echo $gdata-&gt;Post; ?&gt;&lt;/p&gt;&lt;br/&gt;
              &lt;/div&gt;
  
  
          &lt;/div&gt;
  &lt;div class="post-image-space"&gt;&lt;/div&gt;
      &lt;?php endwhile;?&gt;
  </code></pre>