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

bind radgrid based on selected readtree node

1 Answer 55 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
beeta one
Top achievements
Rank 1
beeta one asked on 05 Nov 2012, 11:32 AM
hii,
how can i bind radgrid based on the selected radtree node ?
thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Nov 2012, 12:08 PM
Hi Hash,

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
beeta one
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or