我已经将GridView添加到我的网页上的PlaceHolder,并且将它的数据源设置为linq查询。麻烦的是,当控制运行时虽然gv.DataBind();
它会爆炸我的脸上返回一个对象没有设置bla bla bla错误。Dynamic GridView AllowPaging在DataBind上返回错误
堆栈跟踪看起来像
在System.Web.UI.WebControls.GridView.get_StateFormatter() 在System.Web.UI.WebControls.GridView.BuildCallbackArgument(的Int32的PageIndex) 的系统。 Web.UI.WebControls.GridView.CreateNumericPager(行的TableRow,PagedDataSource pagedDataSource,布尔addFirstLastPageButtons) 在System.Web.UI.WebControls.GridView.InitializePager(GridViewRow行的Int32 columnSpan,PagedDataSource pagedDataSource) ....
和我的代码是
var query = from list in dc.mytable
select list;
gv.DataSource = query.ToList();
gv.DataBind();
这是个问题吗?如果没有,您可能会更有帮助将其作为问题发布,然后发布您的答案。 – MatthewMartin
你明白了。谢谢! – Will