views:

8

answers:

0

It seems that as soon as I click the button the treeview changes selected node to null. Is it because cliking on anything else unselets the node? how can I make the value persist so that I can use it inside the button click event?

button click

protected void Button1_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "-----";
        TextBox8.Text = TreeView1.SelectedNode.Value;
        //if some node is selected
        if (TreeView1.SelectedNode != null)
        {
            TextBox1.Text = "here";

            //case 1:feature is selected
            if (TreeView1.SelectedNode.Depth > 0)
            {
                TextBox1.Text = "depth > 0 ";

            }
            //case 2:version is selected, only change version, date and status
            else
            { 
                string version = TextBox2.Text;
                XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument();
                XmlNodeList nodeList = xmlDoc.SelectNodes("Releases/Release[@version='" + version + "']");
                //XmlNodeList nodeList = xmlDoc.SelectNodes("Persons/Person[contains(Id,"+Id+")]");


                nodeList[0].ChildNodes[1].InnerText = TextBox4.Text;
                nodeList[0].ChildNodes[2].InnerText = TextBox5.Text;
                TextBox1.Text = "saved";
                //xmlDoc.Save(Server.MapPath("./")+"/App_Data/hi.xml");
                XmlDataSource1.Save();

            }
        }
    }