Solved

Displaying image in datalist

Posted on 2008-06-13
2
4,097 Views
Last Modified: 2013-11-26
Hi, I have a page that displays one record from a database table using a datalist. One of the fields contains an image url. My problem is that I cannot get it to display the actual image. I have tried adding an image control but I get error message "error creating control" in design view.
See the code snippet.
The image control is where the problem is. The entry in the database is "~/images/dbpicture.jpg" (without quotes).
Any help greatly appreciated.
Thanks,
NL
C
    <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1">
        <ItemTemplate>
            <asp:Label ID="P_NameLabel" CssClass="bigtext" runat="server" Text='<%# Eval("P_Name") %>' /><br />
            <asp:Label ID="P_DateLabel" CssClass="smalltext" runat="server" Text='<%# Eval("P_Date", "{0:d}") %>' />
            <br />
            
            <table style="width: 80%; border:0px;">
                <tr>
                    <td>
                        <!--problem on next line!!-->
<asp:Image runat="server" ID="P_ImageLabel" ImageUrl="<%# Eval("P_Image") %>" />
                        
                       
                    </td>
                    <td>
                        <asp:Label ID="P_DescLabel" runat="server" Text='<%# Eval("P_Desc") %>' />
                    </td>
                </tr>
            </table>
            <br />
            <br />
            <asp:Label ID="P_PriceLabel" CssClass="bigtext" runat="server" Text='<%# Eval("P_Price", "{0:C}") %>' />
            
            Number in stock:<asp:Label ID="P_StockLabel" runat="server" Text='<%# Eval("P_Stock") %>' />
            <br />
            
            <br />
        </ItemTemplate>
    </asp:DataList>

Open in new window

0
Comment
Question by:nedlogan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 19

Accepted Solution

by:
Melih SARICA earned 250 total points
ID: 21778024
<asp:Image runat="server" ID="P_ImageLabel" ImageUrl='<%# Eval("P_Image") %>' />
0
 
LVL 2

Author Closing Comment

by:nedlogan
ID: 31466877
Thanks for your help.
NL
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question