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

[Solved] persist settings on radgrid?

2 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mac
Top achievements
Rank 1
mac asked on 29 Jun 2009, 10:34 PM
hi.. I'm trying to follow alon the lines of this white paper. http://www.telerik.com/help/aspnet-ajax/grdsavingsettingsonperuserbasis.html
I have a class file (perist.vb) containing the class. I am confused on how to use the example however
my code behind is as follows . THe class from the white paper  file is verbatim copy/paste
Imports Telerik.Web.ui  
Partial Class temp_somepage  
    Inherits System.Web.UI.Page  
    Dim x As PersistMe   
 
    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit  
        If Session("Settings") IsNot Nothing Then  
            x.LoadSettings(Session("Settings"))  
        End If  
    End Sub  
    Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender  
        Session("Settings") = x.SaveSettings  
    End Sub  
End Class 

when trying to run it.. i end up with the object reference not set to object  session("settings") = x.savesettings.
Can you please assist on this as I see I am returning the settings of the grid on savesettings... however I don't see how the GridInstance is to be used.  Thank you.

2 Answers, 1 is accepted

Sort by
0
mac
Top achievements
Rank 1
answered on 30 Jun 2009, 04:36 PM
I would like to bump this as I have an update.
I switched to using the profile class but am still experiencing the same problems of trying to use the SaveSettings() function. my vb code is pasted. What am i doing wrong? The function is not calling for any params....so how would it know that I am targting radgrid1?

Imports Telerik.Web.ui  
Public Class temp_somepage  
    Inherits System.Web.UI.Page  
    Dim x As PersistMe  
 
    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init  
        If Not String.IsNullOrEmpty(Profile.Grid1) Then  
            x.LoadSettings(Profile.Grid1)  
        End If  
    End Sub  
 
    Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)  
        MyBase.Render(writer)  
        If String.IsNullOrEmpty(Profile.Grid1) Then  
            Profile.Grid1 = x.SaveSettings   
' Crash every time with Object reference not set to an instance of an object.   
 
        End If  
    End Sub  
 
End Class  
 
0
Yavor
Telerik team
answered on 02 Jul 2009, 11:07 AM
Hi mac,

I suspect the problem is rooted in trying to access the session values in the Init event handler. You can put a break point there, and verify that the values are available at that stage. If they are not, you can try loading the settings in the PageLoad/grid_PreRender event handlers.

Kind regards,
Yavor
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.
Tags
Grid
Asked by
mac
Top achievements
Rank 1
Answers by
mac
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or