This is a migrated thread and some comments may be shown as answers.

GridView to RadGrid w/ SEO Paging

2 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ronnie
Top achievements
Rank 1
Ronnie asked on 26 Feb 2009, 09:14 PM
Hello,

I'm having a problem converting my standard ASP.NET GridView with it's settings to a RadGrid solution.  I've been struggling with this trying different options, but with no solution.

I have a page with an ASP.NET GridView, a DropDownList for "ItemsPerPage" selector, and a custom pager that uses the querystring to pass the pageNumber to my ObjectDataSource for SEO friendliness, I have EnablePaging="false".  Everything here works fine, both the customer pager and the DDL for selecting the pageSize.

I'm trying to convert all of this to use the RadGrid, RadComboBox, and was hoping to use the RadGrid's pager functionality using EnableSEOPaging, or even use my custom pager, but either instance is causing a problem.  Here are the options I've tried with partial success, each causing a different and frustrating conundrum.

Option 1)  Using the RadGrid with it's pager and EnableSEO="true" SEOPagingQueryStringKey="page".  This works GREAT !!
But my RadComboBox for the "ItemsPerPage" only works on the current page, when selecting "next page" the pageSize of the RadComboBox does not persist to the next page, it sets itself back to the Default pageSize.  (I'm thinking it has something to do with setting the PageSize of either the RadGrid, or the MasterTableView)

Option 2)  Using the RadGrid and Pager Template like in the sample at: Page Template Demo.  Once again, this works GREAT !!, the PagerTemplate with the paging and RadComboBox for "ItemsPerPage" set in the MasterTableView works !, but I can't seem to get EnableSEOPaging to work for template paging.  I know that SEO is automatically enabled when it spots a spider, but it's really important that I have this available for users,  they have the option to do a query with various filters and save it as a "Favorite" search page for later use.

So, my questions are, working backwords...
With option 2) Is there a way to EnableSEOPaging with template paging, either programmatically, javascript, or otherwise ?
OR
With option 1)  Get the RadComboBox for "ItemsPerPage" (which is outside the RadGrid) to persist and not reset.
Here's the code that I used in my standard GridView and DropDownList that works:
protected void Page_Load(object sender, EventArgs e) 
      { 
         if (!this.IsPostBack) 
         { 
            // Set the page size as indicated in the config file. If an option for that size 
            // doesn't already exist, first create and then select it. 
            int pageSize = Globals.Settings.Entities.PageSize; 
            if (ddlItemsPerPage.Items.FindByValue(pageSize.ToString()) == null
               ddlItemsPerPage.Items.Add(new ListItem(pageSize.ToString(), pageSize.ToString())); 
            ddlItemsPerPage.SelectedValue = pageSize.ToString(); 
             
            gvwEntities.PageSize = pageSize; 
            gvwEntities.DataBind(); 
         } 
      } 
 
      protected void ddlItemsPerPage_SelectedIndexChanged(object sender, EventArgs e) 
      { 
         gvwEntities.PageSize = int.Parse(ddlItemsPerPage.SelectedValue); 
         gvwEntities.PageIndex = 0; 
         gvwEntities.DataBind(); 
      } 

And, here is the code (very similiar) after changing to a RadGrid and RadComboBox, but doesn't change the PageSize for every page, only the current page:
protected void Page_Load(object sender, EventArgs e) 
      { 
         if (!this.IsPostBack) 
         { 
            // Set the page size as indicated in the config file. If an option for that size 
            // doesn't already exist, first create and then select it. 
            int pageSize = Globals.Settings.Entities.PageSize; 
            if (rcbItemsPerPage.Items.FindItemByValue(pageSize.ToString()) == null
               rcbItemsPerPage.Items.Add(new RadComboBoxItem(pageSize.ToString(), pageSize.ToString())); 
            rcbItemsPerPage.SelectedValue = pageSize.ToString(); 
 
            rgdEntities.PageSize = pageSize; 
            rgdEntities.DataBind(); 
         } 
      } 
 
      protected void rcbItemsPerPage_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
      { 
         rgdEntities.PageSize = int.Parse(rcbItemsPerPage.SelectedValue); 
         rgdEntities.CurrentPageIndex = 0; 
         rgdEntities.DataBind(); 
      } 

Sorry for the lengthy post, I just wanted to be as clear as possible, I hope I was.
Any assistance in getting either option to work would be greatly appreciated.

Thank you in advance,
Ronnie











2 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 04 Mar 2009, 04:07 PM
Hello Ronnie,

You can try default pager with SEOPaging enabled from Beta release of Q1 for RadControls for ASP.NET AJAX. This is the pager from the demo which you are pointing build in RadGrid.

However if you need to use custom pager template you will have to manually handle SEO paging and set proper postback url of buttons inside pager.

Note that Buttons must be changed with LinkButtons or HyperLinks.

Kind regards,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ronnie
Top achievements
Rank 1
answered on 06 Mar 2009, 03:10 PM
Thank you Nikolay,

I'll look into these options and try them out.

Ronnie
Tags
Grid
Asked by
Ronnie
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Ronnie
Top achievements
Rank 1
Share this question
or