Hi
I have a application in VS2010 in which I am using RadPersistenceManager but getting error when trying to save state of RadGrid. I have attached Error and posting the code. Please help me....
here is the asp code
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication3.WebForm1" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.qsf-demo-canvas
{
background: url(bg_img.jpg) no-repeat;
height: 441px;
width: 476px;
}
.demo-canvas-inner
{
height: 100%;
margin-left: -11px;
padding-top: 26px;
}
.controls-container
{
clear: both;
padding-top: 40px;
zoom: 1;
}
.controls-container:after
{
content: "";
clear: both;
display: block;
}
.controls-container .rlbItem
{
height: 20px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<telerik:RadPersistenceManager runat="server" ID="RadPersistenceManager1">
<PersistenceSettings>
<telerik:PersistenceSetting ControlID="rgdemo" />
</PersistenceSettings>
</telerik:RadPersistenceManager>
<asp:Label ID="Label1" runat="server" />
<br />
<div style="margin-left: 40px" class="qsf-ib">
<telerik:RadButton ID="SaveButton" runat="server" Text="Save state" OnClick="SaveButton_Click"
Skin="Office2007" />
<telerik:RadButton ID="ResetButton" runat="server" Text="Reset state" OnClick="ResetButton_Click"
Skin="Office2007" />
<telerik:RadButton ID="LoadButton" runat="server" Text="Load state" OnClick="LoadButton_Click"
Enabled="false" Skin="Office2007" />
</div>
<div>
<telerik:RadGrid runat="server" ID="rgdemo" EnableHeaderContextMenu="true" EnableHeaderContextAggregatesMenu="true"
Skin="Office2007" EnableHeaderContextFilterMenu="true">
</telerik:RadGrid>
</div>
<asp:HiddenField runat="server" ID="SessionID" />
</div>
</form>
</body>
</html>
---------------------------------------------------Here is the codbehind-------------------
Imports System.IO
Imports Telerik.Web.UI
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Public Function GetData() As DataTable
Dim table As New DataTable()
table.Columns.Add("ID")
table.Columns.Add("ParentID")
table.Columns.Add("Value")
table.Columns.Add("Text")
table.Rows.Add(New [String]() {"1", Nothing, "World_Continents", "World Continents"})
table.Rows.Add(New [String]() {"2", Nothing, "World_Oceans", "World Oceans"})
table.Rows.Add(New [String]() {"3", "1", "Asia", "Asia"})
table.Rows.Add(New [String]() {"4", "1", "Africa", "Africa"})
table.Rows.Add(New [String]() {"5", "1", "Australia", "Australia"})
table.Rows.Add(New [String]() {"6", "1", "Europe", "Europe"})
table.Rows.Add(New [String]() {"7", "1", "North_America", "North America"})
table.Rows.Add(New [String]() {"8", "1", "South_America", "South America"})
table.Rows.Add(New [String]() {"9", "2", "Arctic_Ocean", "Arctic Ocean"})
table.Rows.Add(New [String]() {"10", "2", "Atlantic_Ocean", "Atlantic Ocean"})
table.Rows.Add(New [String]() {"11", "2", "Indian_Ocean", "Indian Ocean"})
table.Rows.Add(New [String]() {"12", "2", "Pacific_Ocean", "Pacific Ocean"})
table.Rows.Add(New [String]() {"13", "2", "South_Ocean", "SouthOcean"})
Return table
End Function
Protected Sub SaveButton_Click(ByVal sender As Object, ByVal e As EventArgs)
SessionID.Value = Guid.NewGuid().ToString()
LoadButton.Enabled = True
RadPersistenceManager1.StorageProviderKey = SessionID.Value
RadPersistenceManager1.SaveState()
End Sub
Protected Sub LoadButton_Click(ByVal sender As Object, ByVal e As EventArgs)
If File.Exists((Server.MapPath("~/App_Data") & "\") + SessionID.Value) Then
RadPersistenceManager1.StorageProviderKey = SessionID.Value
RadPersistenceManager1.LoadState()
Else
Label1.Text = "Please save some state before load it"
End If
End Sub
Protected Sub ResetButton_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub rgdemo_NeedDataSource(ByVal Sender As Object, ByVal e As GridNeedDataSourceEventArgs) Handles rgdemo.NeedDataSource
rgdemo.DataSource = GetData()
End Sub
End Class
I have a application in VS2010 in which I am using RadPersistenceManager but getting error when trying to save state of RadGrid. I have attached Error and posting the code. Please help me....
here is the asp code
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication3.WebForm1" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.qsf-demo-canvas
{
background: url(bg_img.jpg) no-repeat;
height: 441px;
width: 476px;
}
.demo-canvas-inner
{
height: 100%;
margin-left: -11px;
padding-top: 26px;
}
.controls-container
{
clear: both;
padding-top: 40px;
zoom: 1;
}
.controls-container:after
{
content: "";
clear: both;
display: block;
}
.controls-container .rlbItem
{
height: 20px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<telerik:RadPersistenceManager runat="server" ID="RadPersistenceManager1">
<PersistenceSettings>
<telerik:PersistenceSetting ControlID="rgdemo" />
</PersistenceSettings>
</telerik:RadPersistenceManager>
<asp:Label ID="Label1" runat="server" />
<br />
<div style="margin-left: 40px" class="qsf-ib">
<telerik:RadButton ID="SaveButton" runat="server" Text="Save state" OnClick="SaveButton_Click"
Skin="Office2007" />
<telerik:RadButton ID="ResetButton" runat="server" Text="Reset state" OnClick="ResetButton_Click"
Skin="Office2007" />
<telerik:RadButton ID="LoadButton" runat="server" Text="Load state" OnClick="LoadButton_Click"
Enabled="false" Skin="Office2007" />
</div>
<div>
<telerik:RadGrid runat="server" ID="rgdemo" EnableHeaderContextMenu="true" EnableHeaderContextAggregatesMenu="true"
Skin="Office2007" EnableHeaderContextFilterMenu="true">
</telerik:RadGrid>
</div>
<asp:HiddenField runat="server" ID="SessionID" />
</div>
</form>
</body>
</html>
---------------------------------------------------Here is the codbehind-------------------
Imports System.IO
Imports Telerik.Web.UI
Public Class WebForm1
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Public Function GetData() As DataTable
Dim table As New DataTable()
table.Columns.Add("ID")
table.Columns.Add("ParentID")
table.Columns.Add("Value")
table.Columns.Add("Text")
table.Rows.Add(New [String]() {"1", Nothing, "World_Continents", "World Continents"})
table.Rows.Add(New [String]() {"2", Nothing, "World_Oceans", "World Oceans"})
table.Rows.Add(New [String]() {"3", "1", "Asia", "Asia"})
table.Rows.Add(New [String]() {"4", "1", "Africa", "Africa"})
table.Rows.Add(New [String]() {"5", "1", "Australia", "Australia"})
table.Rows.Add(New [String]() {"6", "1", "Europe", "Europe"})
table.Rows.Add(New [String]() {"7", "1", "North_America", "North America"})
table.Rows.Add(New [String]() {"8", "1", "South_America", "South America"})
table.Rows.Add(New [String]() {"9", "2", "Arctic_Ocean", "Arctic Ocean"})
table.Rows.Add(New [String]() {"10", "2", "Atlantic_Ocean", "Atlantic Ocean"})
table.Rows.Add(New [String]() {"11", "2", "Indian_Ocean", "Indian Ocean"})
table.Rows.Add(New [String]() {"12", "2", "Pacific_Ocean", "Pacific Ocean"})
table.Rows.Add(New [String]() {"13", "2", "South_Ocean", "SouthOcean"})
Return table
End Function
Protected Sub SaveButton_Click(ByVal sender As Object, ByVal e As EventArgs)
SessionID.Value = Guid.NewGuid().ToString()
LoadButton.Enabled = True
RadPersistenceManager1.StorageProviderKey = SessionID.Value
RadPersistenceManager1.SaveState()
End Sub
Protected Sub LoadButton_Click(ByVal sender As Object, ByVal e As EventArgs)
If File.Exists((Server.MapPath("~/App_Data") & "\") + SessionID.Value) Then
RadPersistenceManager1.StorageProviderKey = SessionID.Value
RadPersistenceManager1.LoadState()
Else
Label1.Text = "Please save some state before load it"
End If
End Sub
Protected Sub ResetButton_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Protected Sub rgdemo_NeedDataSource(ByVal Sender As Object, ByVal e As GridNeedDataSourceEventArgs) Handles rgdemo.NeedDataSource
rgdemo.DataSource = GetData()
End Sub
End Class