private DataTable table = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
}
}
private void ShowTreeView(string nodeId, TreeNode nodeTemp)
{
DataView dv = table.DefaultView;
dv.RowFilter = string.Format("PARENT_NODE ='{0}'", nodeId);
dv.Sort = "ORDER_NO ASC";
foreach (DataRowView drv in dv)
{
TreeListNode node = new TreeListNode();
node.Text = drv["TASK_NAME"].ToString();
node.Value = drv["NODE_ID"].ToString();
node.ShowCheckBox = _ShowCheckBox;
node.RowInfo.ID = drv["TEMPLATE_ID"].ToString();
node.OnCheckedFunName = "onCheckNode";
node.RowInfo.Attributes.Add("onmouseover", "onMouseOver(this);");
node.RowInfo.Attributes.Add("onmouseout", "onMouseOut(this);");
TreeListColumn td0 = new TreeListColumn(drv["TASK_NAME"].ToString());
td0.CssClass = "FileListtd";
td0.Width = "800px";
node.Columns.Add(td0);
if (nodeId == "0")
{
this.tree.Nodes.Add(node);
}
else
{
nodeTemp.ChildNodes.Add(node);
}
ShowTreeView(node.Value, node);
}
}
private void Bind()
{
table = new SqlHelper().R_DT(string.Format(@"select template_id,node_id,order_no,parent_node,task_name from TIMING_TEMPLATE order by ORDER_NO"), "dt");
DataView dv = table.DefaultView;
dv.RowFilter = "PARENT_NODE ='0'";
ShowTreeView("0", null);
}
在跟踪的时候发现第一次是有效的,但是以后就无效的,求救了~~~
用DataView dv = dt.Select("filter","sort");试试吧
if (!IsPostBack)
{
Bind();//回发后是不会再执行了
}