Are you trying to use the exapdn on demand feature? Here's a short snippet
that does that:
<script runat="server">
void OnPopulate(object sender, TreeNodeEventArgs e)
{
string path = Server.MapPath(e.Node.Value);
foreach (string directory in Directory.GetDirectories(path))
{
string name = Path.GetFileName(directory);
TreeNode n = new TreeNode(name, e.Node.Value + "/" + name);
n.PopulateOnDemand = true;
e.Node.ChildNodes.Add(n);
}
}
</script>
<asp:TreeView ExpandDepth="0" runat="server"
OnTreeNodePopulate="OnPopulate">
<Nodes>
<asp:TreeNode PopulateOnDemand="true"
Text="Root" Value="~" />
</Nodes>
</asp:TreeView>
-Brock
DevelopMentor
http://staff.develop.com/ballen
> ASP.NET 2.0 TreeView
>
[quoted text clipped - 26 lines]
>
> Jamie
Frank - 30 Nov 2005 07:41 GMT
I have very simlar problems as follow code:
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TreeView ID="TreeView1" runat="server"
OnTreeNodePopulate="TreeView1_TreeNodePopulate" ExpandDepth="0">
<Nodes>
<asp:TreeNode PopulateOnDemand="True"
SelectAction="SelectExpand" Text="Root" Value="c:\project">
</asp:TreeNode>
</Nodes>
</asp:TreeView>
</div>
c# code behind:
protected void Page_Load(object sender, EventArgs e)
{
//TextBox1.Text = Request.Browser.SupportsCallback.ToString();
TextBox1.Text = DateTime.Now.ToString();
}
protected void TreeView1_TreeNodePopulate(object sender,
TreeNodeEventArgs e)
{
TreeNode node = e.Node;
if (node != null)
{
if (node.ChildNodes.Count == 0)
InitNode(node);
}
}
private void InitNode(TreeNode node)
{
string path = node.Value;
string[] dirs = Directory.GetDirectories(path);
foreach (string dir in dirs)
{
TreeNode child = new TreeNode(Path.GetFileName(dir), dir);
node.ChildNodes.Add(child);
child.PopulateOnDemand = true;
child.SelectAction = TreeNodeSelectAction.SelectExpand;
//child.Expanded = Directory.GetDirectories(dir).Length == 0 ?
false : true;
}
}
I put a textbox to show DateTime.Now in this page, I found textbox change
when I click or expand a tree node. So, that means this page post back to
server. I think I have set every thing I need to set. I still can not see
client side populate.
> Are you trying to use the exapdn on demand feature? Here's a short snippet
> that does that:
[quoted text clipped - 55 lines]
> >
> > Jamie