Rad Tree View with select

2 posts, 0 answers
  1. Raja
    Raja avatar
    3 posts
    Member since:
    Sep 2012

    Posted 26 Sep 2012 Link to this post

    Hi,
    Is there any samples for bind RadGridView based on selected RadTreeView

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

    Posted 27 Sep 2012 Link to this post

    Hi Raja,

    I suppose you want to bind the RadGrid based on the SelectedNode of RadTreeView. Here is the sample code that I tried.

    ASPX:
    <telerik:RadTreeView ID="RadTreeView1" DataFieldID="id" DataFieldParentID="parent" DataSourceID="SqlDataSource1" DataTextField="name" DataValueField="id" runat="server" onnodeclick="RadTreeView1_NodeClick">
    </telerik:RadTreeView>
    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource2" AutoGenerateColumns="true" Visible="false">
    </telerik:RadGrid>
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT * FROM tree" runat="server"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" runat="server"></asp:SqlDataSource>

    C#:
    protected void RadTreeView1_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
        {
            string text = RadTreeView1.SelectedNode.Text;
            SqlDataSource2.SelectCommand = "select * from tree where name='" + text + "'";
            RadGrid1.Visible = true;
            RadGrid1.Rebind();
        }

    Hope this helps.

    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top