数据绑定:“System.Data.DataRowView'不包含与名称的属性”PRODUCTID“ [英] DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ProductID'

查看:868
本文介绍了数据绑定:“System.Data.DataRowView'不包含与名称的属性”PRODUCTID“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友我正确绑定与数据集的下拉,但它给这个错误:
我的codeS是:

Friends i have properly bind the dropdown with dataset but it is giving this error: my codes are:

要绑定-数据集

 DataSet ds = new ViewAction().GetAllProductInfoData();
            ddlprdctname.DataSource = ds;
            ddlprdctname.DataTextField = "ProductName";
            ddlprdctname.DataValueField ="ProductID";
            ddlprdctname.DataBind();

和GetAllProductInfoData()函数是

and GetAllProductInfoData() function is

 public DataSet GetAllProductInfoData()
        {
            SqlCommand cmd = DataConnection.GetConnection().CreateCommand();
            cmd.CommandText = "Select ProductID ProductName,SubCategory2ID,CompanyID,Price,Quantity,Description from ProductInfo";
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            cmd.Dispose();
            DataConnection.CloseConnection();
            return ds;
        }

什么是错误,请HELLP我解决

What is the error please hellp me to solve

推荐答案

您丢失后的ProductID 在查询一个逗号。由于写的,它是理解产品名称要返回的列名的别名的为的ProductID ,而不是你最有可能打算单独列。

You are missing a comma in your query after ProductID. As written, it is understanding ProductName to be the returned column name alias for ProductID, and not a separate column as you most likely intended.

您书面查询等效于:

Select ProductID AS ProductName, SubCategory2ID, ...

这篇关于数据绑定:“System.Data.DataRowView'不包含与名称的属性”PRODUCTID“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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