How to set Radzen.Blazor's Pager starting page on load?

Hey there! I'm using Radzen.Blazor components on my project and everything's working fine.
I'm now setting URL parameters when changing the page on the Pager component so we can go back to it if we click on the "Back" button on the browser.

My issue is: how can I set the Pager's starting page on page load?
For example, if I have ?page=2 on the URL, I would like the Pager to be set on the 2nd page.

Is this possible? I've tried several solutions but none of them worked...

Thank you in advance. Any help is appreciated.

Here is a possible approach:


1 Like

Thank you a lot for your answer :slight_smile:

Unfortunately, I'm getting the System.NullReferenceException: 'Object reference not set to an instance of an object.' error. It's this error that always keeps me from implementing a solution like this.
Do you have any idea why this might be?

Most probably you’ve missed to set the pager variable with @ref attribute - see my first screenshot for reference.

I followed your screenshot and added the @ref.
It still didn't work :frowning:

image

I’m afraid that I’m not sure why you have such error.

I was able to make it work :slight_smile:

Using the code you provided me, I just changed the "if(firstRender)" to "if(!firstRender)" and everything worked.

For some reason the Pager element wasn't loaded yet during the firstRender...