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

Rad Tree View with select

1 Answer 48 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Raja
Top achievements
Rank 1
Raja asked on 26 Sep 2012, 03:42 PM
Hi,
Is there any samples for bind RadGridView based on selected RadTreeView

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Sep 2012, 06:14 AM
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.
Tags
TreeView
Asked by
Raja
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or