Since I'm not familiar with everything RadGrid and RadWindow can do, I'm wondering if I'm re-inventing the wheel and these controls already do some of this, or something similar.
I have some pretty static data I don't want to query often to save trips. So I thought I'd have the Cache hold the data until 20 minutes after it's no longer requested. (It seems to work, but I've never used the Cache before, so I'm not sure of the pros and cons.) Anyway, I have a RadGrid on an aspx page. Below is the example code behind against the Northwind DB. The aspx page is referenced by a RadWindow that makes it popup modally.
Like I said, I'm wondering if I'm doing more than necessary, or if I'm doing some bad/inefficient coding in regard to your controls, or even in general. Thanks for any input you can give.
Imports System.Data |
Partial Class MyRadGrid |
Inherits System.Web.UI.Page |
Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource |
Dim strSQL As String |
strSQL = "SELECT SupplierID, ContactName, City, Region, PostalCode, Country FROM Suppliers" |
Dim strCacheName As String = "SupplierData" |
Dim ds As DataSet = CType(Cache(strCacheName), DataSet) |
If ds Is Nothing Then |
Dim aDB As New AccessDataSource("~/App_Data/Northwind.mdb", strSQL) |
Dim mydv As System.Data.DataView = CType(aDB.Select(DataSourceSelectArguments.Empty), System.Data.DataView) |
Dim dt As DataTable = mydv.ToTable |
ds = New DataSet |
ds.Tables.Add(dt) |
Cache.Insert(strCacheName, ds, Nothing, Cache.NoAbsoluteExpiration, New System.TimeSpan(0, 0, 20)) |
End If |
RadGrid1.DataSource = ds |
End Sub |
End Class |