求一个demo:TreeView动态绑定菜单后 另外一个页面的gridview根据treeview所选节点ID动态绑定数据
TreeView动态绑定菜单后 另外一个页面的gridview根据treeview所选节点ID动态绑定数据TreeView动态绑定已经实现 TreeView gridview 绑定数据 --------------------编程问答-------------------- 自顶~~~~~~急啊 --------------------编程问答-------------------- protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.TreeView1.Dispose();
GetdataToTable();
InitTree(this.TreeView1.Nodes, "0");
}
}
TreeNode tnNode;
private void InitTree(TreeNodeCollection tnc, string parentId)
{
DataView dv = new DataView();
dv.Table = ds.Tables["Table"];
dv.RowFilter = "PId=" + parentId;
foreach (DataRowView drv in dv)
{
tnNode = new TreeNode();
tnNode.Value = drv["Id"].ToString();
tnNode.Text = drv["Name"].ToString();
tnc.Add(tnNode);
InitTree(tnNode.ChildNodes, tnNode.Value);
}
}
DataSet ds;
private void GetdataToTable()
{
string sql = "select * from Categories";
ds = DBHELP.sele(sql);
}
另一个页面根据id查找 再绑定吧,这好简单的 --------------------编程问答-------------------- id传值通过什么方式? session? --------------------编程问答-------------------- protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
TreeNode node = this.TreeView1.SelectedNode;
if (node.ChildNodes.Count == 0)
{
bind(Convert.ToInt32( node.Value));//为GridView绑定数据
}
}
补充:.NET技术 , ASP.NET