private void BindTree()
{
Tree1.Nodes.Clear();
DataTable table = GetDataTableWithoutZero();
DataSet ds = new DataSet();
ds.Tables.Add(table);
//添加关系
ds.Relations.Add("TreeRelation", ds.Tables[0].Columns["TASKID"], ds.Tables[0].Columns["SUPERID"], false);
foreach (DataRow row in ds.Tables[0].Rows)
{
if (row.IsNull("SUPERID"))
{
ExtAspNet.TreeNode node = new ExtAspNet.TreeNode();
node.NodeID = row["TASKID"].ToString();
node.Text = row["TASKNAME"].ToString();
node.EnablePostBack = true;
node.Expanded = true;
Tree1.Nodes.Add(node);
ResolveSubTree(row, node);
Tree1.SelectedNodeID = node.NodeID;
if (hfSelectedNode.Text == "")
{
hfSelectedNode.Text = node.NodeID;
}
}
}
if (hfSelectedNode.Text != "")
{
Tree1.SelectedNodeID = Tree1.FindNode(hfSelectedNode.Text).NodeID;
}
}
protected void Window1_Close(object sender, EventArgs e)
{
BindTree();
}
hfSelectNode是隐藏控件,记录选中的树节点的ID,每次窗体关闭把hfSelectNode的值赋给Tree1.SelectedNodeID 都不管用,求助,急了一天了
|