Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to make a add to cart page where all the items ill be shown, everything is coming from databsse only the image is hsowing an error, please help

What I have tried:

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ProductImage'.


Line 76:                     <tr>
Line 77:                         <td class="auto-style8">
Line 78:                             <asp:Image ID="Image1" runat="server" Height="160px" ImageUrl='<%# Eval("ProductImage") %>' Width="167px" />
Line 79:                         </td>
Line 80:                     </tr>


these are my codes'
<asp:DataList ID="DataList1" runat="server" CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333" RepeatColumns="4" RepeatDirection="Horizontal" Height="353px" Width="689px" OnSelectedIndexChanged="DataList1_SelectedIndexChanged" OnItemCommand="DataList1_ItemCommand" CssClass="auto-style12" HorizontalAlign="Justify">
         <AlternatingItemStyle BackColor="White" />
        <%-- <FooterStyle BackColor="##507CD1" Font-Bold="True" ForeColor="White" />
         <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />--%>
         <ItemStyle BackColor="#EFF3FB" />
         <ItemTemplate>
             <table border="1" class="auto-style6">
                 <tr>
                     <td class="auto-style4"> PRODUCT ID :
                         <asp:Label ID="Label2" runat="server" Text='<%# Eval("ProductId") %>'></asp:Label>
                          </td>
                 </tr>
                 <tr>
                     <td class="auto-style10">
                         <asp:Label ID="Label3" runat="server" Text='<%# Eval("ProductName") %>'></asp:Label>
                     </td>
                 </tr>
                 <tr>
                     <td class="auto-style8">
                         <asp:Image ID="Image1" runat="server" Height="160px" ImageUrl='<%# Eval("ProductImage") %>' Width="167px" />
                     </td>
                 </tr>
                 <tr>
                     <td class="auto-style11">OMR
                         <asp:Label ID="Label4" runat="server" Text='<%# Eval("ProductPrice") %>'></asp:Label>
                     </td>
                 </tr>
                 <tr>
                     <td class="auto-style10">
                         <asp:ImageButton ID="ImageButton1" runat="server" Height="48px" ImageUrl="~/Medicinepics/Addtocart.jpg" Width="223px" CommandName="addtocart" CommandArgument='<%#Eval("ProductId") %>' />
                     </td>
                 </tr>
             </table>
             <br />
             <br />
         </ItemTemplate>
         <SelectedItemStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
     </asp:DataList>
     </div>
     <asp:SqlDataSource ID="SqlDataSource1" runat="server" OnSelecting="SqlDataSource1_Selecting" ConnectionString="<%$ ConnectionStrings:SMZConnection %>" SelectCommand="SELECT * FROM [Product Detail]"></asp:SqlDataSource>

this is my table
CREATE TABLE [dbo].[Product Detail] (
    [Id]            INT           IDENTITY (1, 1) NOT NULL,
    [ProductId]     INT           NULL,
    [ProductName]   VARCHAR (150) NULL,
    [ProductPrice]  VARCHAR (50)  NULL,
    [ProductImage] VARCHAR (150) NULL
);


like this i have saved in database'
Medicinepics/advil.jpg
Posted
Comments
Richard Deeming 19-May-22 7:00am    
The error would suggest that the ProductImage column doesn't exist in your table. Are you sure you're looking at the correct database?
ramsha naaz 19-May-22 7:06am    
its in the right database only, how to paste an image i can show you the link
TNCaver 19-May-22 12:32pm    
If you connect to that database in SQL Server Management Studio and run your query SELECT * FROM [Product Detail], does it return the ProductImage column with the same spelling as in your code?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900