Click here to Skip to main content
15,908,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi
Plz help in resolving.

Error-> DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'BrandName'.
aspx
XML
<asp:Label ID="lblBrandName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"BrandName")%>'></asp:Label>
<asp:DataList ID="dlBrand" RepeatColumns="1" runat="server" Width="100%" OnItemCommand="dlBrand_ItemCommand">
                    <HeaderStyle BackColor="Lavender"/>
                    <ItemStyle  BackColor="Azure"/>
                    <AlternatingItemStyle  BackColor="LightBlue"/>
                    <HeaderTemplate >
                        <table style="width:100%">
                            <tr>
                                <td style="width:25%" align="center">Brand Name</td>
                                <td style="width:45%" align="center">Description</td>
                                <td style="width:15%" align="center">Edit</td>
                                <td style="width:15%" align="center">Delete</td>
                            </tr>
                        </table>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <table style="width:100%">
                            <tr>
                                <td style="width:25%" align="center">
                                    <asp:Label ID="lblBrandName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"BrandName")%>'></asp:Label>
                                </td>
                                <td style="width:45%" align="center">
                                   <img id="imgBrand" alt='<%#DataBinder.Eval(Container.DataItem,"Description")%>' src='<%#DataBinder.Eval(Container.DataItem,"Logo","~/Browse/Images/{0}")%>' runat="server" width="100" height="75" />
                             </td>
                            <td style="width:15%" align="center">
                                    <asp:ImageButton ID="IbtnBrandEdit" AlternateText="Edit Record" ImageUrl="~/Admin/AdminCatalog/Images/edit.gif" CommandName="Edit" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"ID")%>' runat="server" />
                                </td>
                                <td style="width:15%" align="center">
                                    <asp:ImageButton ID="IbtnBrandDelete" AlternateText="Delete Record" ImageUrl="~/Admin/AdminCatalog/Images/delete.gif" CommandName="Delete" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"ID")%>' runat="server" />
                                </td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </asp:DataList>

aspx.cs
C#
private void BindList()
   {
       DataSet ds = ProductController1.GetAllProducts();
       lblMsg.Text = "";
       if (ds.Tables[0].Rows.Count > 0)
       {
           dlProduct.DataSource = ds;
           dlProduct.DataBind();
       }
       else
       {
           lblMsg.Text = "No such Item !!! Please add one";
       }
   }

stored procedure
SQL
ALTER procedure [dbo].[spGetAllBrand]
AS
select BrandName,Description from tblBrands where Active=1
Posted
v2
Comments
[no name] 22-Sep-12 21:12pm    
And does the table in ds that you are binding to have a column named "BrandName"?
Please post codes of function GetAllProducts().

1 solution

Hi,

In your DataSet there is no column available with BrandName name. Check typo mistake in GetAllProducts. Although you have not posted code of GetAllProducts but error says that you need to verify the column name. If you do not have any class of product to store products then this should work fine. try to add one column description and check if it works for you ?

Thanks
 
Share this answer
 

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