运行后不会提示已有该节点,为什么?
<%@ Page Language= "C# " AutoEventWireup= "true " CodeBehind= "WebForm3.aspx.cs " Inherits= "WebApplication1.WebForm3 " %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:TreeView ID= "TreeView1 " runat= "server ">
<Nodes>
<asp:TreeNode Text= "根 " Value= "根 ">
<asp:TreeNode Text= "qq " Value= "qq "> </asp:TreeNode>
<asp:TreeNode Text= "aa " Value= "aa "> </asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace WebApplication1
{
public partial class WebForm3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TreeNode node = new TreeNode();
node.Value = "aa ";
node.Text = "aa ";
if (!TreeView1.Nodes[0].ChildNodes.Contains(node))
{