views:

333

answers:

3

Dear All, Is Gridview pagination bad? Reason: 1.If javascript is disabled, it will not work. 2.Search engine will not be able to index(I don't know what exactly the reason behind this). Can somebody provide some information?

EDIT: Now I am coding it as :

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
   int newPagenumber = e.NewPageIndex;
   GridView1.PageIndex = newPagenumber;
   GridView1.DataSource = Session["myDataSet"];

   GridView1.DataBind();

}
A: 

Pagination is concept to avoid rendering all the content at a time in a page. This will help in reducing the total size of the page.

If you don't apply pagination to your gridview and your control contains thousands of rows then this will be a horrible experience for the user to wait for the page to load.

You can pull only the number of records that you need for a particular page from database. This will avoid the burden of fetching all the rows and then displaying only the ones that are necessary.

rahul
Probaly I am not very clear.I know that we have to use pagination,thats quite basic, but my question is am I doing it properly? should I try a different approach.
Wondering
A: 

the default implementation of gridview pagination is the worst option for performance as well as SEO. because it loads all data rows from your data source even if its only displaying 10 rows. second, search engines do not index postbacks

however there are many workarounds to sort this problem. implement custom data source to get rid of reading all rows from your data source, and then build your custom control to support seo friendly pager controls (you can even use the new asp.net mvc framework for this quite well)


on a seperate note - i see your code above - this is the worst way to code. never save bulky data in sessions, you would quickly run out of memory if you have too many users... instead use a global cache application, save your most frequently read data in there and use it for display purpose

Raj
can u provide some links or code example for the workarounds.
Wondering
This is just a demo...will implement Caching.
Wondering
A: 

To clarify, are you saying that:

  1. By default the paging controls in a GridView are LinkButtons, which use JavaScript to perform postbacks?
  2. A page with a paginated GridView will only display n records at once (where n is your page size)?

Therefore your concern is that a search engine will only ever see the first n records on your page as it may not follow javascript links? Therefore this could be a concern for SEO if you wish all the records in your datasource to be indexed?

My solution to this would be to use a ListView control, instead, with a DataPager control that uses a QueryString field to pass page number by GET. This would be easily followable by an search engine bot.

Dan Diplo