Solved

Displaying image in datalist

Posted on 2008-06-13
2
4,095 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
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

773 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