这是源码:
DataSet ds = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sql = "select * from proclass";
ds = KennyDataOp.GetDataSet(sql);
AddTree(0, (TreeNode)null, "Product.aspx?cid=");
}
}
public void AddTree(int ParentID, TreeNode pNode,string urls)
{
DataView dvTree = new DataView(ds.Tables[0]);
//过滤ParentID,得到当前的所有子节点
dvTree.RowFilter = "[parentid] = " + ParentID;
foreach (DataRowView Row in dvTree)
{
TreeNode Node = new TreeNode();
if (pNode == null)
{
//添加根节点
Node.Text = Row["name"].ToString();
Node.NavigateUrl = urls + Row["id"].ToString();
this.TreeView1.Nodes.Add(Node);
Node.Expanded = true;
AddTree(Int32.Parse(Row["id"].ToString()), Node, urls); //再次递归
}
else
{
//添加当前节点的子节点
Node.Text = Row["name"].ToString();
Node.NavigateUrl = urls + Row["id"].ToString();
pNode.ChildNodes.Add(Node);
Node.Expanded = true;
AddTree(Int32.Parse(Row["id"].ToString()), Node, urls); //再次递归
}
}
}
我也想不传url 原来我这样写的,但是不知道这个个urls怎么取到后来就直接写:
Node.NavigateUrl = Row["FuncUrl"].ToString() +Row["id"].ToString();
如果按照上面写递归参数urls 怎么取值?
谢谢