Imports Telerik.Web.UI

Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim combo As RadComboBox = CType(Page.FindControl("UserSelection"), RadComboBox)

        Dim user As String = CType(combo.SelectedValue, String)
        Dim SavePersister As New GridSettingsPersister(RadGrid1)
        Session(user) = SavePersister.SaveSettings()
        StatusLabel.Text = "Settings for " + user + " saved successfully!"
        Button2.Enabled = True
    End Sub
    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim combo As RadComboBox = CType(Page.FindControl("UserSelection"), RadComboBox)

        Dim user As String = CType(combo.SelectedValue, String)
        Dim LoadPersister As New GridSettingsPersister(RadGrid1)

        If Session(user) = Nothing Then
            StatusLabel.Text = "No saved settings for this user were found!"
        Else
            Dim settings As String = DirectCast(Session(user), String)
            LoadPersister.LoadSettings(settings)
            StatusLabel.Text = "Settings for " + user + " were restored successfully!"
        End If
    End Sub


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Session(UserSelection.SelectedValue) <> Nothing Then
            Button2.Enabled = True
        Else
            Button2.Enabled = False
        End If

    End Sub
End Class
