treeview控件如何把子节点传递参数出去?
public void PopulateNodes(TreeNodeCollection nodes, Int32 intParentID)
{
DataTable dt = new DataTable();
dt = showmenu.GetProduct_Class;
string strExpression;
strExpression = "[UpID] = " + intParentID;
DataRow[] foundRows;
foundRows = dt.Select(strExpression);
int I;
for (int I = 0; I <= foundRows.GetUpperBound(0); I++) {
TreeNode tn = new TreeNode();
tn.Text = foundRows(I).Item( "ClassName ").ToString();
tn.Value = foundRows(I).Item( "ID ").ToString();
tn.NavigateUrl = foundRows(I).Item( "Url ").ToString;
DataRow[] dr;
dr = dt.Select( "[UpID] = " + tn.Value);
if (dr.GetUpperBound(0) > -1) {
tn.PopulateOnDemand = true;
}
nodes.Add(tn);
}
}
父节点是连接到不同页面,但是子节点是跟父节点同个页面,但是传递不同参数。。
我在数据表建立了一个字段保存节点的URL,现在父节点我可以做到连接不同页面。但是子节点不知道怎么传递参数过去。
------解决方案--------------------if (foundRows(I).Item( "UpID ") == 0) {
tn.NavigateUrl = foundRows(I).Item( "Url ").ToString;
} else {
PassID = Convert.ToInt32(foundRows(I).Item( "ID "));
tn.NavigateUrl = foundRows(I).Item( "Url ") + "?id= " + PassID.ToString;
}
在这里加多个判断。关键是这句tn.NavigateUrl = foundRows(I).Item( "Url ") + "?id= " + PassID.ToString;