title: ASP.net Display Image from SQL
body: <p>Solved: I used handlers. Thanks btw.
  <a href="http://www.aspdotnetcodes.com/Insert_Images_Database.aspx" rel="nofollow">http://www.aspdotnetcodes.com/Insert_Images_Database.aspx</a></p>
  
  <p>How can I display my image inside the DataList1?
  I don't have a clear idea of databinding and such. I hope you guys can help. Thanks
  This is my code for my ASPX</p>
  
  <pre><code>&lt;asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1"&gt;
      &lt;ItemTemplate&gt;
          itemID:
          &lt;asp:Label ID="itemIDLabel" runat="server" Text='&lt;%# Eval("itemID") %&gt;' /&gt;
          &lt;br /&gt;
          Cloth ID:
          &lt;asp:Label ID="Cloth_IDLabel" runat="server" Text='&lt;%# Eval("[Cloth ID]") %&gt;' /&gt;
          &lt;br /&gt;
          Style:
          &lt;asp:Label ID="StyleLabel" runat="server" Text='&lt;%# Eval("Style") %&gt;' /&gt;
          &lt;br /&gt;
          Size:
          &lt;asp:Label ID="SizeLabel" runat="server" Text='&lt;%# Eval("Size") %&gt;' /&gt;
          &lt;br /&gt;
          Color:
          &lt;asp:Label ID="ColorLabel" runat="server" Text='&lt;%# Eval("Color") %&gt;' /&gt;
          &lt;br /&gt;
          Image 1:
          &lt;asp:Image ID="Image1" runat="server" ImageUrl='&lt;%# Eval("[Image 1]") %&gt;' /&gt;
          &lt;br /&gt;
          Image 2:
          &lt;asp:Image ID="Image2" runat="server" ImageUrl='&lt;%# Eval("[Image 2]") %&gt;' /&gt;
          &lt;br /&gt;
          Price:
          &lt;asp:Label ID="PriceLabel" runat="server" Text='&lt;%# Eval("Price") %&gt;' /&gt;
          &lt;br /&gt;
          Notes:
          &lt;asp:Label ID="NotesLabel" runat="server" Text='&lt;%# Eval("Notes") %&gt;' /&gt;
          &lt;br /&gt;
          Alignment of Image 1:
          &lt;asp:Label ID="Alignment_of_Image_1Label" runat="server" 
              Text='&lt;%# Eval("[Alignment of Image 1]") %&gt;' /&gt;
          &lt;br /&gt;
          Alignment of Image 2:
          &lt;asp:Label ID="Alignment_of_Image_2Label" runat="server" 
              Text='&lt;%# Eval("[Alignment of Image 2]") %&gt;' /&gt;
              &lt;br /&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:DataList&gt;
  &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" 
      ConnectionString="&lt;%$ ConnectionStrings:TPSConnectionString %&gt;" 
      SelectCommand="SELECT CustomizedOrder.userid, CustomizedOrder.itemID, ClothInventory.clothID AS [Cloth ID], ClothInventory.style AS Style, ClothInventory.size AS Size, Color.color AS Color, CustomizedOrder.image1 AS [Image 1], CustomizedOrder.image2 AS [Image 2], CustomizedOrder.itemPrice AS Price, CustomizedOrder.notes AS Notes, Alignment.description AS [Alignment of Image 1], Alignment_1.description AS [Alignment of Image 2] FROM CustomizedOrder INNER JOIN ClothInventory ON CustomizedOrder.clothID = ClothInventory.clothID INNER JOIN Color ON ClothInventory.colorID = Color.colorID INNER JOIN Alignment ON CustomizedOrder.alignment1 = Alignment.alignmentID INNER JOIN Alignment AS Alignment_1 ON CustomizedOrder.alignment2 = Alignment_1.alignmentID WHERE (CustomizedOrder.userid = @userid)"&gt;
      &lt;SelectParameters&gt;
  
      &lt;/SelectParameters&gt;
  &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>and this is for the aspx.cs</p>
  
  <pre><code>public partial class addtoShoppingCart : System.Web.UI.Page
  {
      protected void Page_Load(object sender, EventArgs e)
      {
          MembershipUser User = Membership.GetUser();
          object UserGUID = User.ProviderUserKey;
          SqlDataSource1.SelectParameters.Add("userid", UserGUID.ToString());
          SqlDataSource1.DataBind();
      }
  }
  </code></pre>