我在 .aspx 页面上有一个 grdidview 控件,我试图从后面的代码动态连接并绑定 gridview,但不知何故它给我一个错误......这段代码有什么问题?有什么帮助吗?
LinqDataSource LDS_POReport = new LinqDataSource();
LDS_POReport.ContextTypeName = "DataContextDataContext";
LDS_POReport.Selecting += new EventHandler<LinqDataSourceSelectEventArgs>(LinqDataSourcePO_Selecting);
this.gvReport.DataSource = "LDS_POReport";
//this.gvReport.DataBind();
更新:
在我将代码更新为
this.gvReport.DataSource = LDS_POReport;
它工作正常,但是当我尝试排序时出现此错误:
GridView 'gvReport' 触发了未处理的事件排序。
我添加了这个但没有效果。
LDS_POReport.AutoPage = true;
LDS_POReport.AutoSort = true;