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

Advanced Grid Binding generates blank page

3 Answers 58 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hunter
Top achievements
Rank 1
Hunter asked on 06 Aug 2012, 11:20 PM
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>

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 09 Aug 2012, 04:37 PM
Hi Hunter,

Thank you for contacting us.

I examined the proveded code but I was not able to see anything wrong in it. Have you gone through it with the debugged to confirm that the try-catch blocks do not catch any exceptions? If this is not the case, you could open a formal support ticket and send us a runnable project where the issue exposes so we can test it localy and advise you further.

Regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Hunter
Top achievements
Rank 1
answered on 09 Aug 2012, 11:54 PM
Thanks for looking at this issue.  One thing I didn't mention that might be an issue here is that the query is against a MYSQL database.  I was able to get this working with a SQL Data  Source - after I made lots of mods to the generated SQL (you need to remove the brackets and change a couple of other things in the resulting SQL).

However I've been trying to get dynamic bindings to work with the mysql without success.  Any information on problems with MYSQL?
0
Andrey
Telerik team
answered on 14 Aug 2012, 05:49 AM
Hello,

I have answered your question in the support thread you have opened, but I will post the answer here as well, so it could be used from the community.

RadGrid should not have any problems with MySQL.This is true because RadGrid binds to the data that is fetched, not to the way how it is fetched.

I am attaching sample project that illustrates the approach that you need to use.

Kind regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Hunter
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Hunter
Top achievements
Rank 1
Andrey
Telerik team
Share this question
or