Hi,
I have requirement where on 1 main aspx page i have 3 user controls(ascx).
Each ascx has a radgrid.I need to save state of each grid in database individually on gridbutton click.
Tried- I have created a custom storage provider and implemented methods SaveStateToStorage and LoadStateFromStorage.
Now if I apply persistencemanger on any ascx and call .savestate it goes to SaveStateToStorage and all works fine.
But if I move persistencemanger to aspx and apply persistencemangerproxy on ascx nothing works.
Sample code-
on aspx- <telerik:RadPersistenceManager ID="mainPersistenceManager" runat="server"> </telerik:RadPersistenceManager>
on aspx.vb- pageload event - mainPersistenceManager.StorageProvider = New SettingsStorageProvider() 'This is my custom storage provider
on ascx- <telerik:RadPersistenceManagerProxy ID="PersistenceManagerProxy1" runat="server" UniqueKey ="1">
<PersistenceSettings>
<telerik:PersistenceSetting ControlID="radgrid1" />
</PersistenceSettings>
</telerik:RadPersistenceManagerProxy>
on ascx.vb- on button click event-
Dim ascxPersistenceManager As RadPersistenceManager
ascxPersistenceManager = RadPersistenceManager.GetCurrent(Page)
ascxPersistenceManager.PersistenceSettings.AddSetting("radgrid1")
SettingsStorageProvider.StorageProviderKey = Key
ascxPersistenceManager .SaveState()
Now on button click i get exception that it could not find control with id=radgrid1
but if i comment this line "ascxPersistenceManager.PersistenceSettings.AddSetting("radgrid1")"
somehow it calls "LoadStateFromStorage" of my custom storage provider rather than "SaveStateToStorage" method.
Incase when i dont use proxy and put persistencemanger in ascx only it hits correct method but not in case of proxy.
Please help
Thanks,
Ankita
11 Answers, 1 is accepted
I would recommend you to examine the following help article which elaborates more on persisting multiple grid with RadPersistenceManagerProxy. The hoe to article demonstrates how to persist the grid setting by using the default storage provider but the approach is similar when using a custom one.
Regards,
Kostadin
Telerik

Hi Kostadin,
Thanks but I already tried that one,not helping.I have added the unique key to the proxy in user control html itself.
If you see the code i wrote its similar,however it's still not working.
If I add the radgrid control of ascx to the instance of radpersistencemanager it throws exception of control not found.
However if I don't, as I already mentioned in the post on savestate the LoadStateFromStorage method of custom storage is called rather than the SaveStateToStorage method of custom storage class.
Can you please help me with this or provide an example working solution of custom storage(implementing IStateStorageProvider ) having a main aspx page and 2 ascx both having a radgrid.
Like the one I m trying to do.
Thanks,
Ankita

Hi,
Can someone provide any helpful details.
Thanks,
Ankita
Could you please let me know which version of the Telerik Web UI for ASP.NET you are using? I would recommend you to use the latest version and check whether your sample is working correctly. Additionally I would suggest you to test the sample from my previous reply and let me know whether the sample is working in your case. I would appreciate if you can replicate the issue in the provided sample, so I can examine it locally.
Regards,
Kostadin
Telerik

I'm using version - 2014.2.618.45 ,However i tried with the latest dll too, but again same thing is happening.
On calling savestate method of radpersistencemanager the LoadStateFromStorage method of my storage provider class is getting called though SaveStateToStorage method should be called in this case.
This is happening only when I m using the proxy on user control.
If I just implement radpersistence manager on user control ans then call the savestate method , the correct SaveStateToStorage method of custom storage class is called.
My code of main page and user control is there in my first post.Its same as in the example link provided earlier by you.
I m attaching my custom storage provider code.
You can use this vb file in the project and check the issue.
I have been stuck on this issue for quite a long time now, nothing seems to be happening at all and it's very frustrating.
Very much appreciate any help in resolving this issue asap.
I prepared a small sample where I used custom storage provider and user controls. Could you please check it out and let me know how it differs form your real setup?
Regards,
Kostadin
Telerik

Hello,
I have the same problem as Ankita. When I call in my ascx.cs savestate method of radpersistencemanager the LoadStateFromStorage method of my storage provider class is getting called though SaveStateToStorage method should be called in this case.
Your example I couldn't use because the control which I need to add to RadPersistenceManagerProxy comes from parent page and not directly from ascx.
Please help me to solve this issue. My dlls are 2016.2.809.40, I have also tried some older but without success.
Best regards
Vasssek
Could you please prepare a small runnable sample and send it to us in order to investigate it further? I tried to replicate the issue in the previously provided sample but on my side works correctly. Please check out the attached sample and let me know how it differs from your real setup?
Regards,
Kostadin
Telerik by Progress

Hello,
Since I have not enough time to test this for you, I have done some small workaround which is quite sufficient for me.
Here it is:
Before I call save method of radpersistance I store some value about saving process into session variable. Next step inside LoadStateFromStorage method I check whether this session variable exists or not. If yes then immediately return. If no, it continues with loading state...
Strange thing is that when I return from LoadStateFromStorage method then SaveStateToStorage is called. And that's what I want from the very beginning. Save grid persistance...
Maybe this whole issue is caused because of nested user control inside RadPageView with RadTabSstrip...
Best regards
Vasssek

I'm having the same issue. It appears that the state isn't being saved properly.
I have a Master Page, with Content pages and a custom storage provider.
in my page load, I'm calling LoadState if not postback. In PreRenderComplete, I call SaveState if is postback. So that column changes in my grid are saved immediately after they change.
On first pass, when I step through the code, I hit the call to SaveState, but that immediately goes into LoadStateFromStorage in my custom storage provider, which is nothing since it has never been saved before (no cookie exists, so call returns string.Empty). Once that call returns, it immediately goes into the SaveStateFromStorage, but at that point, the state being saved is the original empty one, since that is what loaded before going into SaveStateFromStorage.
Why is it doing this?
Thank you for the detailed explanation. Unfortunately, it is not enough to pinpoint the root of the problem. Can you, please, open a standard support ticket and attach a runnable simplified version of your project in it, where we can reproduce and debug the problem further?
Thank you in advance for your cooperation.
Regards,
Vessy
Progress Telerik