Treview in combo AND load data from behind

2 posts, 0 answers
  1. Guss
    Guss avatar
    48 posts
    Member since:
    Apr 2008

    Posted 01 Oct 2008 Link to this post

    I have combined the two examples. (Treeview in combobox AND Load on demand from code behind)

    The problem is the reference to the treeview.
    <telerik:RadComboBox ID="RadComboBoxSD" runat="server"
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        <ItemTemplate> 
            <div id="div1"
                <telerik:RadTreeView runat="server" ID="RadTreeViewSD"  > 
                    <CollapseAnimation Duration="100" Type="OutQuint" /> 
                    <ExpandAnimation Duration="100" /> 
                </telerik:RadTreeView> 
            </div> 
        </ItemTemplate> 
        <Items> 
            <telerik:RadComboBoxItem Text="" /> 
        </Items> 
    </telerik:RadComboBox> 
     
     
     
        private void LoadRootNodes() 
        { 
            RadTreeView RadTreeViewSD = (RadTreeView)RadComboBoxSD.FindControl("RadTreeViewSD"); 
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["RemoteSqlServerData"].ConnectionString); 
            SqlCommand selectCommand = new SqlCommand("SELECT [id],[regionName] FROM tRegion ORDER BY regionName", connection); 
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommand); 
            DataTable data = new DataTable(); 
            adapter.Fill(data); 
            foreach (DataRow row in data.Rows) 
            { 
                RadTreeNode node = new RadTreeNode(); 
                node.Text = row["regionName"].ToString(); 
                node.Value = row["id"].ToString(); 
                node.ExpandMode = TreeNodeExpandMode.ServerSide; 
                RadTreeViewSD.Nodes.Add(node); 
            } 
        } 

    RadTreeView RadTreeViewSD = (RadTreeView)RadComboBoxSD.FindControl("RadTreeViewSD"); does not work.
    RadTreeViewSD.Nodes.Add(node) - object is null

    Please help, Ive search the site and found the client side way of doing this. How do you do this server side?


  2. Guss
    Guss avatar
    48 posts
    Member since:
    Apr 2008

    Posted 01 Oct 2008 Link to this post

    Don't worry, I have it:

    RadTreeView RadTreeViewSD = (RadTreeView)RadComboBoxSD.Items[0].FindControl("RadTreeViewSD");

Back to Top