I've added a GridView to a PlaceHolder on my web page, and am setting it's datasource to a linq query. The trouble is that when control runs though gv.DataBind();
it'll blast on my face returning an Object not set bla bla bla error.
The stack trace looks like
at System.Web.UI.WebControls.GridView.get_StateFormatter() at System.Web.UI.WebControls.GridView.BuildCallbackArgument(Int32 pageIndex) at System.Web.UI.WebControls.GridView.CreateNumericPager(TableRow row, PagedDataSource pagedDataSource, Boolean addFirstLastPageButtons) at System.Web.UI.WebControls.GridView.InitializePager(GridViewRow row, Int32 columnSpan, PagedDataSource pagedDataSource) ....
and my code is
var query = from list in dc.mytable
select list;
gv.DataSource = query.ToList();
gv.DataBind();