小编Ric*_*ton的帖子

Dynamic GridView AllowPaging在DataBind上返回错误

我已经在我的网页上添加了一个GridView到PlaceHolder,并将它的数据源设置为linq查询.麻烦的是,当控制运行虽然gv.DataBind();它会爆炸我的脸上返回一个对象没有设置bla bla bla错误.

堆栈跟踪看起来像

System.Web.UI.Web.Controls.GridView.CreateNumericPager上的System.Web.UI.WebControls.GridView.BuildCallbackArgument(Int32 pageIndex)中的System.Web.UI.Web.trol.WebControls.GridView.get_StateFormatter()处于Table.Web.UI.Web.Controls.GridView.CreateNumericPager(TableRow row,PagedDataSource pagedDataSource,Boolean 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();
Run Code Online (Sandbox Code Playgroud)

c# linq data-binding gridview

3
推荐指数
1
解决办法
944
查看次数

标签 统计

c# ×1

data-binding ×1

gridview ×1

linq ×1