我在数据列表中出现错误

编程入门 行业动态 更新时间:2024-10-11 21:26:21
本文介绍了我在数据列表中出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 嗨 请帮助解决问题. 错误-> DataBinding:"System.Data.DataRowView"不包含名称为"BrandName"的属性. aspx

< asp:Label ID =" lblBrandName" runat =" 服务器" 文本 =' <%#DataBinder.Eval(Container.DataItem," BrandName")%> ' > < /asp:Label > < asp:DataList ID =" dlBrand" RepeatColumns =" 1 " runat =" 服务器" 宽度 =" > 100%" OnItemCommand =" dlBrand_ItemCommand" > ; < HeaderStyle BackColor =" 薰衣草" / > < ItemStyle BackColor =" Azure" / > < AlternatingItemStyle BackColor =" LightBlue" / > < HeaderTemplate > < 表 =" width:100%" > < tr > < td =" width:25%" align =" 中心" > 品牌名称< /td > < td =" width:45%" align =" 中心" > 说明< /td > < td =" width:15%" align =" 中心" > 编辑< /td > < td =" width:15%" align =" 中心" > 删除< /td > < /tr > < /table > < /HeaderTemplate > < ItemTemplate > < 表 =" width:100%" > < tr > < td =" width:25%" align =" 中心" > < asp:Label ID =" lblBrandName" runat =" 服务器" 文本 =' <%#DataBinder.Eval(Container.DataItem," BrandName")%> ' > < /asp:Label > < /td > < td =" width:45%" align =" 中心" > < img id =" imgBrand" alt =' <%#DataBinder.Eval(Container.DataItem," 描述" )%> ' src =' <%# DataBinder.Eval(Container.DataItem," 徽标" , " 〜/浏览/图片/{0}" )%> ' runat =" 服务器" 宽度 =" 100" 高度 =" 75" / > < /td > < td =" width:15%" align =" 中心" > < asp:ImageButton ID =" IbtnBrandEdit" AlternateText =" 编辑记录" ImageUrl =" 〜/Admin/AdminCatalog/Images/edit.gif" CommandName =" Edit" CommandArgument =' <%#DataBinder.Eval(Container.DataItem," ID" )%> ' runat =" 服务器" / > < /td > < td =" width:15%" align =" 中心" > < asp:ImageButton ID =" IbtnBrandDelete" AlternateText =" 删除记录" ImageUrl =" 〜/Admin/AdminCatalog/Images/delete.gif" CommandName =" 删除" CommandArgument =' <%#DataBinder.Eval(Container.Da taItem," ID" )%> ' 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

更多推荐

我在数据列表中出现错误

本文发布于:2023-11-30 22:10:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651620.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:我在   出现错误   数据   列表中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!