treeview的跟节点是手工加进去的,可是其他子子节点是从数据库中取出来的,请问如何实现选中跟节点以后所有的子节点也选中,谢谢了。
Microsoft.Web.UI.WebControls.TreeNode tnRoot = new Microsoft.Web.UI.WebControls.TreeNode();
tnRoot.Text = "地区列表";//跟节点
tnRoot.CheckBox = true;
Microsoft.Web.UI.WebControls.TreeNode tnClient;
DataTable dt = new DataTable();
foreach(DataRow dr in dt.Rows)
{
tnClient = new Microsoft.Web.UI.WebControls.TreeNode();
tnClient.Text = dr["v_bmmc"].ToString();
tnClient.CheckBox = true;
tnRoot.Nodes.Add(tnClient);
}
Microsoft.Web.UI.WebControls.TreeNode tnRoot = new Microsoft.Web.UI.WebControls.TreeNode();
tnRoot.Text = "地区列表";//跟节点
tnRoot.CheckBox = true;
Microsoft.Web.UI.WebControls.TreeNode tnClient;
DataTable dt = new DataTable();
foreach(DataRow dr in dt.Rows)
{
tnClient = new Microsoft.Web.UI.WebControls.TreeNode();
tnClient.Text = dr["v_bmmc"].ToString();
tnClient.CheckBox = true;
tnRoot.Nodes.Add(tnClient);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货