I have used the TreeView with an update panel before. Here is some basic code that i have gotten to work as a prototype before. I can't remember where I got the original sample, but it went something like this:
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TreeView ID="TreeViewFiles" runat="server" OnTreeNodePopulate="TreeViewFiles_TreeNodePopulate">
</asp:TreeView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
Loading .....
</ProgressTemplate>
</asp:UpdateProgress>
and in the code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BuildTree();
}
}
protected void TreeViewFiles_TreeNodePopulate(object sender, TreeNodeEventArgs e)
{
System.Threading.Thread.Sleep(3000);
TreeNode parentNode = e.Node;
PopulateNormal(parentNode);
}
protected void BuildTree()
{
TreeViewFiles.Nodes.Clear();
TreeNode root = new TreeNode("Drives", @"0");
root.SelectAction =
TreeNodeSelectAction.None;
root.PopulateOnDemand = true;
root.Selected = false;
TreeViewFiles.Nodes.Add(root);
TreeViewFiles.ExpandDepth = 1;
root.Expand();
}
protected void PopulateNormal(TreeNode node)
{
string path = node.Value;
try
{
DirectoryInfo directory = new DirectoryInfo(path);
foreach (FileSystemInfo child in directory.GetFileSystemInfos())
{
TreeNode childNode = new TreeNode();
childNode.Text = child.Name;
childNode.Value = child.FullName;
if (child is DirectoryInfo)
{
if (((DirectoryInfo)child).GetFileSystemInfos().Length > 0)
{
childNode.PopulateOnDemand =
true;
}
}
node.ChildNodes.Add(childNode);
}
}
catch
{
// put in try catch because of secruity errors on reading local drive
}
}
Something like that will work. Reading the file directory is a simple way to show the tree will populate. Hope that works for you.