When User Clicked RadTreeview Node Radgrid has to populate

4 posts, 0 answers
  1. noyan
    noyan avatar
    15 posts
    Member since:
    Dec 2008

    Posted 06 Apr 2009 Link to this post

    I got a gridview which I created with following code when user clicked one of treview node I have to populate a radgrid for given departmen. I dont know how can I catch treeview click event and without making any postback populate radgrid for clicked departmen. All help will be apreciated, thank you in advance.

        //Load Root Nodes...  
        private void LoadRootNodes()  
        {  
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Personelcon"].ConnectionString);  
            SqlCommand selectCommand = new SqlCommand("SELECT * FROM Department WHERE Reportsto IS NULL", connection);  
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);  
            DataTable data = new DataTable();  
            adapter.Fill(data);  
     
            foreach (DataRow row in data.Rows)  
            {  
                RadTreeNode node = new RadTreeNode();  
                node.ImageUrl = "themes/default/entity.gif";  
                node.Text = row["Dname"].ToString();  
                node.Value = row["Departmenid"].ToString();  
                node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;  
                RadTreeView1.Nodes.Add(node);  
            }  
        } 
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Apr 2009 Link to this post

    Hello Noyan,

    Try out the following code snippet.

    ASPX:
     
    <telerik:radtreeview id="RadTreeView1" runat="server" OnNodeClick="RadTreeView1_NodeClick">   
    </telerik:radtreeview>   
       
    <telerik:RadGrid ID="RadGrid1" runat="server">   
    </telerik:RadGrid>  
      
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        <AjaxSettings>  
            <telerik:AjaxSetting AjaxControlID="RadTreeView1">  
                <UpdatedControls>  
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />  
                </UpdatedControls>  
            </telerik:AjaxSetting>  
        </AjaxSettings>  
    </telerik:RadAjaxManager> 

    CS:
     
    protected void LoadRootNodes()  
    {  
        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Personelcon"].ConnectionString);  
        SqlCommand selectCommand = new SqlCommand("SELECT * FROM Department WHERE Reportsto IS NULL", connection);  
        SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);  
        DataTable data = new DataTable();  
        adapter.Fill(data);  
        foreach (DataRow row in data.Rows)  
        {  
            RadTreeNode node = new RadTreeNode();  
            node.ImageUrl = "themes/default/entity.gif";    
            node.Text = row["Dname"].ToString();  
            node.Value = row["Departmenid"].ToString();    
            node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;  
            RadTreeView1.Nodes.Add(node);  
        }    
    }  
     
    protected void RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs e)  
    {  
        SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Personelcon"].ConnectionString);  
        SqlCommand selectCommand = new SqlCommand("SELECT * FROM Department WHERE Departmenid='" + e.Node.Value + "'", connection);  
        SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);  
        DataTable data = new DataTable();  
        adapter.Fill(data);  
        RadGrid1.DataSource = data;  
        RadGrid1.Rebind(); 

    Adding AJAX Manager will avoid unnecessary page flickering.

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lakshmi
    Lakshmi avatar
    1 posts
    Member since:
    Mar 2014

    Posted 17 Aug 2015 in reply to Shinu Link to this post

    Hi Shinu,

    Thank you for your solution.

    I was using the same code but i could not populate the grid onNodeClick event.

    during debug i did not get any errors the grid is getting binded but i could not see the grid on the page.

    If any one face the same issue please help me if you are aware of the solution.

    Thank you,

    Lakshmi

  5. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 20 Aug 2015 Link to this post

    Hello Lakshmi,

    Please open a new support ticket for the RadGrid control and attach your solution. We will need to investigate the problem in order to give you direction what might be causing this behavior. Make sure that the AjaxManger is updating the grid control when the TreeView is doing a postback. For the purpose of the test you could remove the AjaxManager to be sure that everything is working as expected. 

    Regards,
    Peter Filipov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top