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

Treview in combo AND load data from behind

1 Answer 38 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Guss
Top achievements
Rank 2
Guss asked on 01 Oct 2008, 01:20 PM
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?


1 Answer, 1 is accepted

Sort by
0
Guss
Top achievements
Rank 2
answered on 01 Oct 2008, 01:26 PM
Don't worry, I have it:

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

Tags
TreeView
Asked by
Guss
Top achievements
Rank 2
Answers by
Guss
Top achievements
Rank 2
Share this question
or