本文介绍了DataBinding:'System.Data.DataRowView'不包含名为'id'的属性。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





这里我将数据绑定到下拉列表,但如果有可能帮我感谢我会收到错误



我的代码是:



Hi,

Here i am binding data to dropdownlist, but i got error if it possible help me thanks

my code is:

string Qry = "select c.category from category c inner join ProductAdd pa on pa.categoryid =c.id where pa.id='"+strEdited+"'";
               dt = adpro.GetData(Qry);
               if (dt.Rows.Count > 0)
               {
                   ddlcategory.DataSource = dt;
                   ddlcategory.DataTextField = "category";
                   ddlcategory.DataBind();
               }

推荐答案

string Qry = "select c.id, c.category from category c inner join ProductAdd pa on pa.categoryid =c.id where pa.id='"+strEdited+"'";
 dt = adpro.GetData(Qry);
               if (dt.Rows.Count > 0)
               {
                   ddlcategory.DataSource = dt;
                   ddlcategory.DataTextField = "category";
ddlcategory.DataTextValue="id";
                   ddlcategory.DataBind();
               }


这篇关于DataBinding:'System.Data.DataRowView'不包含名为'id'的属性。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 09:28