I'm trying to bind a radgrid with NeedDataSource. The NeedDataSource routine is fired and I can step through it and it the datatable is filled with data. But when I let this run to completion it generates a blank page. I'm new to telerik controls so I'm sure I've overlooked some easy thing here.
<%@ Page Title="" Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="MySql.Data.MySqlClient" %>
<
script
runat
=
"server"
>
Protected Sub rgAlertsNeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs)
Dim Priorities As String = ""
Dim dtSelectedDate As DateTime = DateTime.Now.AddDays(-7)
Dim dtEndSelectedDate As DateTime = DateTime.Now
Dim HoursToPST As Integer = -8 'ddlTimeZone.SelectedValue - 8 'adjust because alerts are in PST/PDT
'If DateTime.Now().IsDaylightSavingTime Then HoursToGMT = HoursToGMT - 1
dtSelectedDate = dtSelectedDate.AddHours(HoursToPST)
dtEndSelectedDate = dtEndSelectedDate.AddHours(HoursToPST)
Dim SQL As String = "SELECT *, "
SQL &= " Case Priority "
SQL &= " WHEN 'Critical' then '5' "
SQL &= " WHEN 'Major' then '4' "
SQL &= " WHEN 'Minor' then '3' "
SQL &= " WHEN 'Warning' then '2' "
SQL &= " WHEN 'FYI' then '1' "
SQL &= " End As Severity"
SQL &= " FROM alert.alerts "
Dim SQLWHERE As String = ""
SQLWHERE = " WHERE EventName like '" & Session("ClientID") & "|%' "
SQLWHERE &= " AND CreationTime BETWEEN '" & dtSelectedDate.ToString("yyyy-MM-dd HH:mm") & "' AND '" & dtEndSelectedDate.ToString("yyyy-MM-dd HH:mm") & "' "
SQL &= SQLWHERE
If Len(Session("OSAlertSortExpr")) > 0 Then
SQL &= " ORDER BY " & Session("OSAlertSortExpr")
Else
SQL &= " ORDER BY CreationTime DESC "
End If
rgAlerts.DataSource = GetDataTable(SQL)
End Sub
Public Function GetDataTable(ByVal SQL As String) As DataTable
Dim conn As MySqlConnection = New MySqlConnection(Session("TC_CONN"))
Dim adapter As MySqlDataAdapter = New MySqlDataAdapter(SQL, conn)
Dim dt As New DataTable
conn.Open()
Try
adapter.Fill(dt)
Finally
conn.Close()
End Try
Return dt
End Function
</
script
>
<
telerik:RadGrid
ID
=
"rgAlerts"
runat
=
"server"
OnNeedDataSource
=
"rgAlertsNeedDataSource"
>
</
telerik:RadGrid
>