I'm building a web page that uses a tree view control. If i click on a particular node i want to redirect a value to the next page .. how to do it using the treeview?
I would greatly appreciate some insight on this.

hi rasmi ,
u can use treeview SelectedNodeChanged event just like selected indexchanged in dropdown list.
below is the example.

<asp:TreeView ID="TreeView1" runat="server" ImageSet="Contacts" NodeIndent="10" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged">
            <ParentNodeStyle Font-Bold="True" ForeColor="#5555DD" />
            <HoverNodeStyle Font-Underline="False" />
            <SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px" />
            <Nodes>
                <asp:TreeNode Text="java" Value="java"></asp:TreeNode>
                <asp:TreeNode Text="sap" Value="sap"></asp:TreeNode>
                <asp:TreeNode Text=".net" Value=".net"></asp:TreeNode>
            </Nodes>
            <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px"
                NodeSpacing="0px" VerticalPadding="0px" />
        </asp:TreeView>

in code behind....
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    {
        string selected = TreeView1.SelectedNode.Value;
        Response.Redirect("~/datalist.aspx?s=" + selected);
    }

may this will helpful....

hi,
okie i will explain u clearly . i have 3 forms. In first form i have dropdownlist where in i have to pass the value of the selectedItem to the third form . From first form i ll redirect the value to the second form(here it necessary to go to the second form) . i have used label to store the the value in the second form.. that value i have to pass to the third form using treeview. please help me slove this problem.

Thanks.

hi rasmi,
so u want to pass first form value to third.so why dont u use session or cookie.so that it u can access through out the application.other wise if u wish to contue ur process then it simple.like..

protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    {
        string selected = TreeView1.SelectedNode.Value;
        Response.Redirect("~/datalist.aspx?s=" + selected);
    }        <asp:TreeView ID="TreeView1" runat="server" ImageSet="Contacts" NodeIndent="10" OnSelectedNodeChanged="TreeView1_SelectedNodeChanged">
            <ParentNodeStyle Font-Bold="True" ForeColor="#5555DD" />
            <HoverNodeStyle Font-Underline="False" />
            <SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px" />
            <Nodes>
                <asp:TreeNode Text="java" Value="java"></asp:TreeNode>
                <asp:TreeNode Text="sap" Value="sap"></asp:TreeNode>
                <asp:TreeNode Text=".net" Value=".net"></asp:TreeNode>
            </Nodes>
            <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px"
                NodeSpacing="0px" VerticalPadding="0px" />
        </asp:TreeView>

in code behind....
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
    {
        string selected = label1.text;        Response.Redirect("~/form3.aspx?value=" + selected);
    }

but here ur passing first form value to second then second to third....that is y session or cookie is the best option..hope it is helpful to u......

Hi,
I have used session .. here is the code in which i have written in the first form to redirect the value to the second form.

Page.Session["Text1"]= dept;
Response.Redirect("Master Form.aspx?code=" +dept);

Using the treeview i tried to redirect the value to from second to the third form . here is the code

protected void TreeView1_SelectedNodeChanged1(object sender, EventArgs e)
    {
        string str = lblyr.Text;
        Page.Session["see1"] = str;
        Response.Redirect("Record Details.aspx?code=" + str);
}

but its not taking the value ..In treeview properties, in node itself i have given the path of the form .

hi,
ya if give the path in node it self.this event will not raise.and i am sugesting u by making changes in ur code here

Session["Text1"]= dept;
Response.Redirect("Master Form.aspx");
//no need pass as query string
page 2:
in pageload some where lese u can write
string val=session["Text1"].ToString();
//here if want u can set this string to any label
//nxt step is as ur using sessions this event is not neccesary as we dont need to pass any values from here(we have values in session with which we can access any where)..but if u want to use i modified this event as...
protected void TreeView1_SelectedNodeChanged1(object sender, EventArgs e)
{
Response.Redirect("Record Details.aspx");
}

let me know if any doubts in this,.....

Here in form 2 if i write the code
string val = session["Text1"].ToString();
in page load i am getting some error as "The name 'session' does not exist in the current context".

hey rasmi,
check the case for session..it should be Session["Text1"].Tostring();
in form 1 also modify.....that....sorry this mistake is due to me only....i always neglect this case sensitivity...
plz check ones.....

This question has already been answered. Start a new discussion instead.