Solved

Displaying image in datalist

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

726 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