DataBinding:' System.Data.DataRowView'不包含名称为'名称'

时间:2016-04-20 04:55:55

标签: c# data-binding

当我试图绑定我的下拉按钮" DataBinding:' System.Data.DataRowView'不包含名称为'名称'的属性。"发生。帮助我克服这一点。提前谢谢。

我正在使用的代码是

var at = _dbConnect.GetData_DataTable("select * from Employee a where a.department = '3' order by Name");
    ddlPerson.DataSource = cat;
    ddlPerson.DataTextField = "Name";
    ddlPerson.DataValueField = "id";
    ddlPerson.DataBind();
    ddlPerson.Items.Add(new ListItem(" MY NAME ", "0"));
    ddlPerson.SelectedValue = "0";

2 个答案:

答案 0 :(得分:0)

数据库字段是“name”而不是“Name”吗?

答案 1 :(得分:0)

var at = _dbConnect.GetData_DataTable("select * from Employee a where a.department = '3' order by Name");
ddlPerson.DataSource = **at**;

感谢您的答案和建议