我有一个带有根节点,子节点和子子节点的树状视图。我需要为每个子子节点添加一个按钮。单击该按钮后,我需要使用该子节点ID填充popupextender。任何帮助将不胜感激。谢谢。
期望的视图:
*根节点
1.child node 1
*(subchild node 1) BUTTON
*(subchild node 2) BUTTON
2.child node 2
*(subchild node 1) BUTTON
*(subchild node 2) BUTTON
<asp:TreeView ID="TreeView1" EnableClientScript="true"
PopulateNodesFromClient="true"
OnTreeNodePopulate="calltree" Font-Size="8pt" runat="server"
ShowLines="True" HoverNodeStyle-Font-Underline="True"
SelectedNodeStyle-Font-Bold="True" ParentNodeStyle-ForeColor="Black">
<Nodes>
<asp:TreeNode Text="Chart Of Cars" Selected="true"
SelectAction="Expand" PopulateOnDemand="true"/>
</Nodes>
</asp:TreeView>
背后的代码。cs:
公共无效调用树(对象发送者,TreeNodeEventArgs e) {
switch (e.Node.Depth)
{
case 0:
HeaderTitle(e.Node);
break;
case 1:
HeaderSubTitle(e.Node);
break;
default:
break;
}
}
public void HeaderTitle(TreeNode node)
{
DataSet ds_ParentNode = objcon.GetDataSet("select distinct
ProfileID,profilename from profile");
foreach (DataRow row in ds_ParentNode.Tables[0].Rows)
{
TreeNode newNode = new TreeNode();
newNode.Text = row["ProfileID"].ToString() + ' ' + row["profilename"].ToString();
newNode.Value = row["ProfileID"].ToString();
newNode.Expanded = false;
newNode.SelectAction = TreeNodeSelectAction.Expand;
newNode.PopulateOnDemand = true;
node.ChildNodes.Add(newNode);
}
}
public void HeaderSubTitle(TreeNode node)
{
DataSet ds_SubNode = objcon.GetDataSet("select distinct Profileext,profilepart from profilesert where ProfileID='" + node.Value + "'");
foreach (DataRow row in ds_SubNode.Tables[0].Rows)
{
TreeNode newNode = new TreeNode();
newNode.Text = row["Profileext"].ToString() + ' ' + row["profilepart"].ToString();
newNode.Value = row["Profileext"].ToString();
newNode.Expand();
newNode.SelectAction = TreeNodeSelectAction.Expand;
newNode.PopulateOnDemand = true;
newNode.Expanded = false;
node.ChildNodes.Add(newNode);
}
}