Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4101
  • Last Modified:

Displaying image in datalist

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
nedlogan
Asked:
nedlogan
1 Solution
 
Melih SARICACommented:
<asp:Image runat="server" ID="P_ImageLabel" ImageUrl='<%# Eval("P_Image") %>' />
0
 
nedloganAuthor Commented:
Thanks for your help.
NL
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now