Error in pagination of the gridview in ASP. net2.0

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.