I wrapped a gridview control myself and made an error when creating the paging function, which is interesting.
This is an error
Code When the gridview executes the databind function.
At system. Web. UI. webcontrols. gridview. buildcallbackargument (int32 pageindex)
At system. Web. UI. webcontrols. gridview. createnumericpager (tablerow row, pageddatasource, Boolean
Addfirstlastpagebuttons)
At system. Web. UI. webcontrols. gridview. initializepager (gridviewrow row, int32 columnspan, pageddatasource
Pageddatasource)
At system. Web. UI. webcontrols. gridview. createrow (int32 rowindex, int32 perfOrmanceindex, datacontrolrowtype
Rowtype, datacontrolrowstate rowstate, Boolean databind, object dataitem, datacontrolfield [] fields,
tablerowcollection rows, pageddatasource)
at system. web. UI. webcontrols. gridview. createchildcontrols (ienumerable datasource, Boolean databinding)
at system. web. UI. webcontrols. compositedataboundcontrol. extends mdatabinding (ienumerable data)
at system. web. UI. webcontrols. gridview. extends mdatabinding (ienumerable data)
at system. web. UI. webcontrols. databoundcontrol. ondatasourceviewselectcallback (ienumerable data)
at system. web. UI. performanceview. select (datasourceselectarguments arguments, datasourceviewselectcallback
callback)
at system. web. UI. webcontrols. databoundcontrol. performselect ()
at system. web. UI. webcontrols. basedataboundcontrol. databind ()
at system. web. UI. webcontrols. gridview. databind ()
at maxplatform. UI. web. controls. entitygrid. binddata (Object parent) in
looks like an error occurred while creating the page number. The prompt is "the object has not been applied to the instance ".
code when using this control
entitygrid grid = new entitygrid ();
grid. binddata (this);
cell. controls. add (GRID);
However, during the test, there was no problem with the gridview paging. What was the problem?
This is the HTML code generated by the gridview when it runs correctly. It uses js to execute callback.
<A href = "javascript :__ dopostback ('ctl01 $ cph_webpart_manager $ WPM $ ve_viewplace $ view_common_grid $ ctl13 $ ctl02 ','') "> page 2nd </a>
The JS :__ dopostback function uses the control path to call back: 'ctl01 $ cph_webpart_manager $ WPM $ ve_viewplace $ view_common_grid $ ctl13 $ ctl02 '. This is the key.
The previous error occurs here: the path has an error. Because of the two statements:
Grid. binddata (this );
Cell. Controls. Add (GRID );
That is, the JS build path fails when the control is loaded to the parent control.
In turn:
Cell. Controls. Add (GRID );
Grid. binddata (this );
That is to say, place the control first, determine its path, and then bind it to let JS generate the callback code. As a result, the exception just now disappears.
Key issues are:
The gridview is the path immediately used to build JS callback in databind.
Source: http://blog.aspcool.com/dlwang2002/archive/2005/08/05/2615.html