Geting " no data to display message" even though my datasource has data

3 posts, 0 answers
  1. fred williams
    fred williams avatar
    55 posts
    Member since:
    Feb 2010

    Posted 24 Jun 2016 Link to this post

    So I'm binding the data to the treelist via datatable. It defintely has data (over 2000 rows), and I'm using the needsdatasource event handler to bind. It must be recognizing SOMETHING because after it binds, the column names from the data appear in the list it just show no data. VS 2015 is that makes a difference. Code below:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="xxx.aspx.cs" Inherits="" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html>
    <head runat="server">
        <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
        <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
                <telerik:RadDateTimePicker runat="server" ID="datePicker" Width="175px"></telerik:RadDateTimePicker><asp:Button runat="server" ID="btnLoad" Text="Load" OnClick="btnLoad_Click" /><asp:Button runat="server" ID="btnExport" OnClick="btn_Export_Click" Text="Export To Excel" /><br />
                    <telerik:RadTreeList ID="RadTreeList1" runat="server" AllowPaging="true" PageSize="3" DataKeyNames="USERID"
                       OnNeedDataSource="RadTreeList1_NeedDataSource"  ParentDataKeyNames="CustomerID">

    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
        public partial class Tracker : System.Web.UI.Page
            protected void Page_Load(object sender, EventArgs e)
                datePicker.SelectedDate = DateTime.Now;
            protected void RadTreeList1_NeedDataSource(object sender, Telerik.Web.UI.TreeListNeedDataSourceEventArgs e)
                var dt = GetDataSource();
                RadTreeList1.DataSource = dt;
            protected void btnLoad_Click(object o,EventArgs e)
            protected void btn_Export_Click(object o,EventArgs e)
                RadTreeList1.ExportSettings.Excel.Format = TreeListExcelFormat.Biff;
            public DataTable GetDataSource()
                var dt = new DataTable();
                var strQuery = "";
                strQuery += " select ";
                strQuery += " USERID [CustomerID]";
                strQuery += ", USERID ";
                strQuery += ", FileInput";
                strQuery += ", MeterNo ";
                strQuery += ", MeterName ";
                strQuery += " ,LastReadTime ";
                strQuery += " from xx i ";
                strQuery += " JOIN xxx u ON u.CustomerID = i.USERID ";
                strQuery += " where ConnectionDevice = 18 AND isActive=1";
                strQuery += " and u.isParent = 1 ";
                strQuery += " AND Time<@Time ";
                strQuery += " order by userid,fileinput,meterno";
                using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["xxx"].ConnectionString))
                    var cmd = new SqlDataAdapter(strQuery, con);
                    cmd.SelectCommand.Parameters.AddWithValue("@Time", "11/1/2015");
                return dt;

    Like I said it displays the treelist with all the columns from the query and corresponding datatable fine, but it's not displaying any data despite having 2000+records. 


  2. fred williams
    fred williams avatar
    55 posts
    Member since:
    Feb 2010

    Posted 24 Jun 2016 in reply to fred williams Link to this post

    Are there any kind of data integrity requirements (ie. foregin key relationships, etc) that I could be missing?
  3. Kostadin
    Kostadin avatar
    1733 posts

    Posted 29 Jun 2016 Link to this post

    Hello Fred,

    I would recommend you to examine the following help article which elaborates more on RadTreeList structure and the data needed to populate it. Generally your ParentDataKeyName should point to a DataKey or to a default value of the data type. You can also check out the following binding help article where a binding to a simple object is demonstrated.

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top