Please tell me if I am doing this treeview correctly. Thank you.

  • Thread starter Thread starter jm
  • Start date Start date
J

jm

<%@ Page Language="c#" autoeventwireup="false" %>
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls"
Assembly="Microsoft.Web.UI.WebControls" %>
<script runat="server">

void Page_load(object sender, EventArgs e) {


// Create the first TreeNode
TreeNode tvFirst = new TreeNode();
tvFirst.Text = "First Tree Node";

// Create the second TreeNode
TreeNode tvSecond = new TreeNode();
tvSecond.Text = "Second Tree Node";

// Add the second TreeNode as a child of the first
tvFirst.Nodes.Add(tvSecond);

// Add the first TreeNode to the TreeView's root TreeNodes
TreeView1.Nodes.Add(tvFirst);
}

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<iewc:TreeView id="TreeView1" runat="server">
<iewc:TreeNodeType></iewc:TreeNodeType>
</iewc:TreeView>
</p>
</form>
</body>
</html>


The page loads with no errors. I simply get nothing on the page
displayed. Is there some method I have to do so that I can see the
nodes I have added? I know treeview works on my system as I can hard
code nodes. Thank you.
 
Hi, jm,

Page_load should be Page_Load in C# because it is case-sensitive language.

Hope this helps
Martin
 
Thanks.

I changed that and it still didn't work. I found that the line:

autoeventwireup="false"

has to be set to true or removed. I don't know if that's a bug or by design.
 
Back
Top