我有一个带有根节点,子节点和子节点的树状视图。单击子节点后,我需要在弹出窗口中获取该节点值及其父节点值。我将提供任何帮助。预先感谢。
*Root Node
1.child node 1
*(subchild node 1)
*(subchild node 2)
2.child node 2
*(subchild node 1)
*(subchild node 2)
<asp:TreeView ID="TreeView1"
OnSelectedNodeChanged="TreeView1_SelectedNodeChanged"
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>
public void calltree(object sender, TreeNodeEventArgs e)
{
switch (e.Node.Depth)
{
case 0:
HeaderTitle(e.Node);
break;
case 1:
LinkURL(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 LinkURL(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.ImageUrl = "~/images/office2003_contacts.gif";
newNode.Expand();
newNode.Expanded = true;
newNode.PopulateOnDemand = false;
node.ChildNodes.Add(newNode);
}
}
<pre> protected void TreeView1_SelectedNodeChanged(object sender,
EventArgs e)
{
int index = TreeView1.Nodes.IndexOf(TreeView1.SelectedNode);
TreeView1.SelectedNode.Selected = true;
if (TreeView1.SelectedNode.Value != "")
{
lbl_supname.Text = TreeView1.SelectedNode.Value;
lbl_drugname.Text = "";
mpe_First.Show();
pnl_First.Visible = true;
UpdatePanel1.Update();
UpdatePanel1_1.Update();
}
else
{
mpe_First.Hide();
//UpdatePanel1.Update();
pnl_First.Visible = false;
UpdatePanel1.Update();
}
}
在子子节点上,单击“我需要在弹出扩展器中获取节点值。但是它显示为空”。