I have combined the two examples. (Treeview in combobox AND Load on demand from code behind)
The problem is the reference to the treeview.
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?
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?