Unable to bind TreeList

2 posts, 0 answers
  1. Sandeep
    Sandeep avatar
    21 posts
    Member since:
    Apr 2013

    Posted 15 May 2013 Link to this post

    Hi All,

    I am unable to bind treelist  , i am using DataKeyNames and ParentDataKeyName are in different columns. could you please help me on this.

    Sandeep Kumar
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 May 2013 Link to this post

    Hi Sandeep,

    Try the following code to bind treelist.

     <%-- simple binding--%>
     <telerik:RadTreeList runat="server" ID="RadTreeList1" AllowPaging="true" PageSize="3" DataKeyNames="EmployeeID"  ParentDataKeyNames="ReportsTo">
    <br /><br />
     <%--  Advanced binding--%>
      <telerik:RadTreeList runat="server" ID="RadTreeList2" AllowPaging="true" PageSize="3" DataKeyNames="EmployeeID" ParentDataKeyNames="ReportsTo" OnNeedDataSource="RadTreeList2_NeedDataSource">

    protected void Page_Load(object sender, EventArgs e)
          if (!IsPostBack)
              RadTreeList1.DataSource = GetDataTable(); //simple binding
    public DataTable GetDataTable()
          String ConnString = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;
          SqlConnection conn = new SqlConnection(ConnString);
          SqlDataAdapter adapter = new SqlDataAdapter();
          adapter.SelectCommand = new SqlCommand("SELECT EmployeeID, LastName, FirstName, Title, TitleOfCourtesy, ReportsTo FROM Employees", conn);
          DataTable myDataTable = new DataTable();
          return myDataTable;
    protected void RadTreeList2_NeedDataSource(object source, TreeListNeedDataSourceEventArgs e)
          RadTreeList2.DataSource = GetDataTable(); //Advance binding

  3. DevCraft R3 2016 release webinar banner
Back to Top