C# DetailsView不使用数据源

C# DetailsView不使用数据源,c#,asp.net,.net,detailsview,C#,Asp.net,.net,Detailsview,我正在尝试使用详细信息视图 这是我的数据源 我从这边经过 IEnumerable<DataRow> row = Connection.GetDataTable([sql]).AsEnumerable(); this.dvOrderInformation.DataSource = row; this.dvOrderInformation.DataBind(); 或 如果我将其直接绑定到DataGrid,它就可以正常工作。你知道我做错了什么吗。你可以调整一下 this.dvOrde

我正在尝试使用详细信息视图

这是我的数据源

我从这边经过

IEnumerable<DataRow> row = Connection.GetDataTable([sql]).AsEnumerable();

this.dvOrderInformation.DataSource = row;
this.dvOrderInformation.DataBind();

如果我将其直接绑定到DataGrid,它就可以正常工作。你知道我做错了什么吗。

你可以调整一下

this.dvOrderInformation.DataSource = Connection.GetDataTable([sql]);
this.dvOrderInformation.DataBind();
注:这是正常的行不包含列,所以他找不到列名

DataField=“OrderID”是
DataColumn。Name

找到了解决方案

this.dvOrderInformation.DataSource = Connection.GetDataSet([sql]);
this.dvOrderInformation.DataBind()
关键是我必须使用数据集,而不是数据表

A field or property with the name 'OrderID' was not found on the selected data source.
this.dvOrderInformation.DataSource = Connection.GetDataTable([sql]);
this.dvOrderInformation.DataBind();
this.dvOrderInformation.DataSource = Connection.GetDataSet([sql]);
this.dvOrderInformation.DataBind()