Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8202979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:23:02+00:00 2026-06-07T07:23:02+00:00

I have a TreeView control in my ASP.NET web application, and I have problems

  • 0

enter image description hereI have a TreeView control in my ASP.NET web application, and I have problems with the event selected node changed, I click on some node in the treeview but the event doesn’t trigger, I have some instructions there that are not executed, I checked with debugger also.

<asp:TreeView ID="ArboreSarcini" runat="server" ImageSet="News" 
onselectednodechanged="ArboreSarcini_SelectedNodeChanged" NodeIndent="10" 
style="z-index: 1; left: 1px; top: 27px; position: absolute; height: 308px; width: 446px">
<HoverNodeStyle Font-Underline="True" BackColor="#99CCCC" Font-Size="12pt" />
<LeafNodeStyle ImageUrl="~/Poze/leaf.png" NodeSpacing="2px" />
<LevelStyles>
<asp:TreeNodeStyle BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" 
Font-Names="Leelawadee" Font-Size="Medium" Font-Underline="False" 
ImageUrl="~/Poze/Root.png" />
<asp:TreeNodeStyle BorderColor="#003300" BorderStyle="Solid" BorderWidth="1px" 
Font-Names="Leelawadee" Font-Underline="False" ImageUrl="~/Poze/node.png" 
Width="400px" />
<asp:TreeNodeStyle BorderColor="#006600" BorderStyle="Solid" BorderWidth="1px" 
Font-Names="Leelawadee" Font-Underline="False" Height="10px" 
ImageUrl="~/Poze/leaf.png" Width="390px" />
</LevelStyles>
<NodeStyle Font-Names="Leelawadee" Font-Size="10pt" ForeColor="Black" 
HorizontalPadding="5px" NodeSpacing="2px" VerticalPadding="0px" 
ImageUrl="~/Poze/node.png" Width="0px" />
<ParentNodeStyle Font-Bold="False" Width="500px" />
<RootNodeStyle ImageUrl="~/Poze/Root.png" />
<SelectedNodeStyle Font-Underline="False" BackColor="#009148" BorderWidth="2px" 
Font-Bold="False" Font-Italic="True" Font-Size="12pt" />
</asp:TreeView>
protected void Button1_Click(object sender, EventArgs e)
{
ArboreSarcini.Nodes.Clear();
populeaza_sarcini();

string sqlstring1 = "Select * from activitati";
System.Data.SqlClient.SqlConnection con1 = new System.Data.SqlClient.SqlConnection(
            "Data Source=BOGDAN-PC\\BOGDAN;Initial Catalog=ePlanning;Integrated Security=SSPI;Connect Timeout=10;TrustServerCertificate=True ");
System.Data.SqlClient.SqlCommand comm1 = new System.Data.SqlClient.SqlCommand(sqlstring1, con1);
System.Data.SqlClient.SqlDataReader reader1;
con1.Open();
reader1 = comm1.ExecuteReader();

while (reader1.Read())
{
foreach (Sarcina s in listaSarcini)
{
    if ((int)reader1["id_sarcina"] == s.Id_sarcina)
    {
        s.ListaActivitati.Add(new Activitate(Convert.ToInt32(reader1["id_activitate"]), reader1["descriere"].ToString()));
    }
}
}

TreeNode tatal = new TreeNode();
tatal.Value = DropListProiecte.SelectedItem.ToString();
//    ArboreSarcini.Nodes.Add(tatal);


TreeNode parentNode = new TreeNode();
foreach (Sarcina sarc in listaSarcini)
{
parentNode = new TreeNode( sarc.Id_sarcina.ToString() + ". " + sarc.Descriere.ToString());


foreach (Activitate act in sarc.ListaActivitati)
{
    TreeNode copil = new TreeNode(act.Id_activitate.ToString()+". "+act.Descriere.ToString() );
    parentNode.ChildNodes.Add(copil);
}
tatal.ChildNodes.Add(parentNode);
//parentNode.Collapse();


}
ArboreSarcini.Nodes.Add(tatal);
con.Close();
ArboreSarcini.ExpandAll();
}


    protected void ArboreSarcini_SelectedNodeChanged(object sender, EventArgs e)
{

    if (ArboreSarcini.SelectedNode.ImageUrl == "~/Poze/node.png")
    {

        System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(
                      "Data Source=BOGDAN-PC\\BOGDAN;Initial Catalog=ePlanning;Integrated Security=SSPI;Connect Timeout=10;TrustServerCertificate=True ");
        //  string de_splituit = ArboreSarcini.SelectedNode.Text;
        string[] id_sarcina = ArboreSarcini.SelectedNode.Text.Split('.');


        string sqlstring = "Select * from sarcini where id_sarcina=" + id_sarcina[0] + ";";




        System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand(sqlstring, con);
        System.Data.SqlClient.SqlDataReader reader;

        con.Open();
        reader = comm.ExecuteReader();
        while (reader.Read())
        {
            tbIDSarcina.Text = reader["id_sarcina"].ToString();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:23:03+00:00Added an answer on June 7, 2026 at 7:23 am

    By default, the TreeView control handles expand-collapse functionality
    on the client unless the browser does not support client script or the
    EnableClientScript property is set to false. If the
    PopulateNodesFromClient property is set to true and the browser
    supports client script, then the TreeView control retrieves the data
    from the server without posting the entire page back.

    When the TreeView control is in selection mode, each time a user
    clicks a node, a postback to the server occurs and the
    SelectedNodeChanged event is raised.

    Typically, you should handle postback events when the TreeView control
    is in selection mode or the nodes are being dynamically populated.
    This is because either the PopulateOnDemand or PopulateNodesFromClient
    property is set to true.

    So kindly verify that you set all the required properties. Sharing your HTML might helpful.
    Read more about the asp.net treeview here
    TreeNode.Nodes Property.
    Gets the collection of TreeNode objects assigned to the current tree node.

    http://msdn.microsoft.com/en-us/library/system.windows.forms.treenode.nodes.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application where I am using asp.net tree view control to
In my asp.net web application, i have a tree view control with checkbox enabled.Now
I have listed data for ASP.net control TreeView. I wanted to disable a particular
I do have a asp:TreeView control on my Asp.net page and when I render
I have web page in ASP.NET. I have created Tree View control with jQuery.
I am using the teleriks treeview control (asp.net mvc extensions), where I may have
I have a ASP.Net TreeView control that I am binding to an XML data
I have a asp.net treeview control that I need to be able to set
I'm working on a very complex ASP.NET Web application. The menu is a Treeview
I have a treeview control in my web application. I build this tree view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.