Solved

Displaying image in datalist

Posted on 2008-06-13
2
4,088 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
Comment Utility
<asp:Image runat="server" ID="P_ImageLabel" ImageUrl='<%# Eval("P_Image") %>' />
0
 
LVL 2

Author Closing Comment

by:nedlogan
Comment Utility
Thanks for your help.
NL
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now