locked
maintain gridview pagesize with viewstate disabled RRS feed

  • Question

  • User-1945566640 posted

    Hi, i have a gridview on my web form that bound to object data source.

    I've enabled paging and DISABLED viewstate for the gridview

    i set gridview page size for exmplae to 20 in form at runtime, after that when i go to another page in gridview, the pagesize reset to 10.

    this functionality works when viewstate for gridview is active but it's inefficient for pages with 100 records on gridview.

    i want to disable view state and maintain gridview pagesize while navigating girdview's pages.

    any ideas?

    tanks in advance.

    Tuesday, August 16, 2011 6:10 AM

Answers

All replies

  • User-573138384 posted

    If you disable ViewState of grid, paging and sorting will not work. You have to customize them in order to work. Create custom pager and by implementing paging logic in database, you can achieve this. This is most recommended if your records to pull are high...

    Refer the following...

    http://www.tipsntracks.com/316/gridview-custom-paging-in-asp-net-3-5-with-sql-server-stored-procedure.html

    http://www.4guysfromrolla.com/articles/031506-1.aspx

    http://forums.asp.net/t/1069129.aspx

    Else enable ViewState for low no of records...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 16, 2011 6:19 AM
  • User-1177472553 posted

    Hi, i have a gridview on my web form that bound to object data source.

    I've enabled paging and DISABLED viewstate for the gridview

    i set gridview page size for exmplae to 20 in form at runtime, after that when i go to another page in gridview, the pagesize reset to 10.

    this functionality works when viewstate for gridview is active but it's inefficient for pages with 100 records on gridview.

    i want to disable view state and maintain gridview pagesize while navigating girdview's pages.

    any ideas?

    tanks in advance.

    so u can do this at run time is in the gridview pageindexchanging event .. set the page size to ur defined value ..

    gridview.PageSize=100;

    Tuesday, August 16, 2011 10:00 AM