Search code examples
asp.netgridviewobjectdatasourcecustompaging

ObjectDataSource: needs to 'show all records' on demand instead of paging


I have a GridView and ObjectDataSource set up to do custom paging and everything was fine. Now the client wants a 'show all' button. In the event handler for this button, what can I do to achieve this?

Thanks for your time.


Solution

  • If you want show all records on a button click, then its better to set AllowPaging = false on the button's Click handler. It will simply disable the paging feature and bind all the records to the gridview:

    Gridview1.AllowPaging = false;
    Gridview1.DataBind();