我在数据列表中出现错误 [英] i got error in data list

查看:83
本文介绍了我在数据列表中出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


请帮助解决问题.

错误-> DataBinding:"System.Data.DataRowView"不包含名称为"BrandName"的属性.
aspx

 <   asp:Label     ID   ="   ="span>    runat   =" 服务器" 文本  "   BrandName")>  <  /asp:Label  > 
<   asp:DataList     ID   ="   RepeatColumns    1 "  runat   服务器" 宽度  > 100%"     ="   dlBrand_ItemCommand" <   HeaderStyle     ="  薰衣草" > 
                    <   ItemStyle     BackColor    Azure"  / > 
                    <   AlternatingItemStyle     BackColor    LightBlue"  / > 
                    <   HeaderTemplate    <      ="  <   tr  > 
                                <   td     ="   align   ="  > 品牌名称<   /td  > 
                                <   td     ="   align   ="  > 说明<  /td  > 
                                <   td     ="   align   ="  > 编辑<  /td  > 
                                <   td     ="   align   ="  > 删除<  /td  > 
                            <  /tr  > 
                        <  /table  > 
                    <  /HeaderTemplate  > 
                    <   ItemTemplate  > 
                        <      ="  <   tr  > 
                                <   td     ="   align   ="  > 
                                    <   asp:Label     ID   ="   runat   服务器" 文本  <%#DataBinder.Eval(Container.DataItem,"  BrandName") >  <  /asp:Label   > 
                                <  /td  > 
                                <   td     ="   align   ="  > 
                                   <   img     ="   imgBrand"  alt   <%#DataBinder.Eval(Container.DataItem," )%> '    src   ='  <%# DataBinder.Eval(Container.DataItem,"  " )   ="  服务器" 宽度  ="    高度  ="    / > 
                             <  /td  > 
                            <   td     ="   align   ="  > 
                                    <   asp:ImageButton     ID   ="   AlternateText   编辑记录"     ImageUrl   =" 〜/Admin/AdminCatalog/Images/edit.gif"  CommandName   ="     CommandArgument   ='  " )%> '    runat   =" 服务器" / <  /td  > 
                                <   td     ="   align   ="  > 
                                    <   asp:ImageButton     ID   ="   AlternateText   删除记录"     ImageUrl   =" 〜/Admin/AdminCatalog/Images/delete.gif"  CommandName   ="     CommandArgument   ='  " )%> '    runat   =" 服务器" / > 
                                <  /td  > 
                            <  /tr  > 
                        <  /table  > 
                    <  /ItemTemplate  > 
                <  /asp:DataList  >  


aspx.cs

 私有 无效 BindList()
   {
       数据集ds = ProductController1.GetAllProducts();
       lblMsg.Text = " ;
       如果(ds.Tables [ 0 ].Rows.Count  >   0 )
       {
           dlProduct.DataSource = ds;
           dlProduct.DataBind();
       }
       其他
       {
           lblMsg.Text = " ;
       }
   }


存储过程

  ALTER  过程 [dbo].[spGetAllBrand]
 AS 
选择品牌名称,说明来自 tblBrands 其中有效= 1 

解决方案



在您的数据集中,没有可用于BrandName name的列.检查GetAllProducts中的拼写错误.尽管您尚未发布GetAllProducts的代码,但错误提示您需要验证列名.如果您没有用于存储产品的任何产品类别,则此方法应该可以正常工作.尝试添加一列描述并检查它是否对您有用?

谢谢


hi
Plz help in resolving.

Error-> DataBinding: ''System.Data.DataRowView'' does not contain a property with the name ''BrandName''.
aspx

<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

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

ALTER procedure [dbo].[spGetAllBrand]
AS
select BrandName,Description from tblBrands where Active=1

解决方案

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


这篇关于我在数据列表中出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆