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;
using System.Data.SqlClient;
using NineRays.WebControls;
public partial class _Defult: System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
AddNodes(flyTreeView.Nodes, \"1\");
}
}
protected void flyTreeView_PopulateNodes(object sender, NineRays.WebControls.FlyTreeNodeEventArgs e)
{
AddNodes(e.Node.ChildNodes, e.Node.Value);
}
private void AddNodes(NineRays.WebControls.FlyTreeNodeCollection flyTreeNodeCollection, string id)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings[\"MyConnectionString1\"].ToString());
SqlDataAdapter da = new SqlDataAdapter(\"select * from drx_department where parent_id=\" + id, conn);
DataSet ds = new DataSet();
da.Fill(ds);
foreach (DataRow row in ds.Tables[0].Rows)
{
FlyTreeNode ftn = new FlyTreeNode();
ftn.Text = row[\"department_name\"].ToString();
ftn.Value = row[\"department_id\"].ToString();
ftn.PopulateNodesOnDemand = true;
try
{
flyTreeNodeCollection.Add(ftn);
}
catch (Exception ex)
{
// add a child node that shows that there was an exception trying to get its child nodes
AddExceptionNode(ftn.ChildNodes, ex);
}
//using recursion the program runs well
//AddNodes(ftn.ChildNodes, ftn.Value);
}
}
private void AddExceptionNode(FlyTreeNodeCollection nodes, Exception ex)
{
FlyTreeNode ftn = new FlyTreeNode();
ftn.Text = HttpUtility.HtmlEncode(ex.Message);
ftn.NodeTypeID = \"errorType\";
nodes.Add(ftn);
}
}
I set a break point in AddNodes function.It pauses When Page_Load and fireing PopulateNodes event in first level.No pause in next level and no exception.
I am very puzzled...