Link to home
Start Free TrialLog in
Avatar of nedlogan
nedloganFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of Melih SARICA
Melih SARICA
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nedlogan

ASKER

Thanks for your help.
NL