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

Paging not working for the previous page button?

9 Answers 278 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pooya
Top achievements
Rank 1
Pooya asked on 29 Sep 2011, 05:32 PM
I have a RadGrid control that has been created dynamically and added to the page.

I have enabled paging for it by setting AllowPaging = true.

I have also set the EnableViewState = true for both RadGrid and its MasterTableView.

I've read this page and am using NeedDataSource event already.

Now, Next Page button works fine and I can see that RadGrid_PageIndexChanged event is raised.

However, when I click the Previous Page button, it doesn't work and indeed the RadGrid_PageIndexChanged event is not raised at all!

Why? How to fix this?

Thanks,

9 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 30 Sep 2011, 09:16 AM
Hi Pooya,

In case you have handled the NeedDataSource event as it is done in this online example, then make sure you are not setting the grid table view data source outside the event and that you are calling the DataBind() method.

Greetings,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Pooya
Top achievements
Rank 1
answered on 30 Sep 2011, 09:56 AM
Hi,

thanks for your reply but like I said the RadGrid is created and added dynamically; that example is for declarative version and doesn't seem to be related?

When adding a RadGrid dynamically, I thought you had said we shouldn't call the DataBind() method?

I have a RadGridBuilder with Build() method that builds my RadGrid:

public RadGrid Build()
        {
            this.DataSource = GetDataSource();

            SetImmediateProperties();

            SetMasterTableView();

            this.RadGrid.Rebind();

            return this.RadGrid;
        }

and NeedDataSource:

 private void RadGridNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            this.RadGrid.DataSource = this.DataSource;
        }

Also, my master table view data source was never set as the master table view uses the RadGrid data source. Please could you explain if it's not this way?

Do you have any example which shows the RadGrid paging works when the RadGrid is defined and added programmatically?

Many thanks,
0
Pooya
Top achievements
Rank 1
answered on 30 Sep 2011, 10:32 AM
I think there is something wrong with viewstate.

When RadGrid.EnableViewState is true:
  • these work: next and last buttons + page numbers apart from 1 + page size
  • these don't work; first page number, first and previous navigation buttons

When RadGrid viewstate is disabled:
  • these work: all page numbers
  • these don't work: all 4 navigation buttons, page size

I have tried different options for ViewStateMode and EnableViewState of PlaceHolder and RadGrid.
0
Pavlina
Telerik team
answered on 30 Sep 2011, 12:25 PM
Hello Pooya,

Please refer to the attached sample project which is working properly and let me know if it helps to resolve the problem you are facing with paging.

I hope this helps.

Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Pooya
Top achievements
Rank 1
answered on 30 Sep 2011, 01:45 PM
Thanks Pavlina; it helped a bit but the sample wasn't for the programmatic creation of the RadGrid.

At which event the DataBind() or Rebind() should be called?

I enabled view state for the RadGrid and called Rebind() at RadGrid_PreRender() event handler and Paging works now.

But this causes the nested tables not to work. also the settings of Export to Excel (e.g. ExportDataOnly = true) stop working.

 
0
Pavlina
Telerik team
answered on 03 Oct 2011, 03:11 PM
Hi Pooya,

Can you please verify that you have followed the instructions from the following help article to create your grid entirely in code behind?
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html

Kind regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Pooya
Top achievements
Rank 1
answered on 03 Oct 2011, 03:17 PM
Yes. I removed the call to RadGrid.Rebind() method completely and everything sorted out!

thanks,
0
Prasanna
Top achievements
Rank 1
answered on 23 Jul 2012, 09:09 PM
Hi,

I am working on RadGrid inside a usercontrol and creating Template colums dynamically.
I have followed the rules of dynamic column creation and I am using the NeedDataSource to assign Datasource property of Radgrid.

The problem that I am facing is that when I click on the Previous, Next buttons of the paging the data does not bind to the Radgrid.
I get the proper number of rows with the header columns but emty rows.

Can any one help!

Thanks in advance.
0
Pavlina
Telerik team
answered on 25 Jul 2012, 08:21 AM
Hi Prasanna,

I suggest you to open a formal support ticket and send us your project, so that we can try to identify the exact reason for the problem.

Regards,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Pooya
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Pooya
Top achievements
Rank 1
Prasanna
Top achievements
Rank 1
Share this question
or