Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Expand TreeView when redirect

Expand TreeView when redirect

Scheduled Pinned Locked Moved ASP.NET
databasehelpdesigndata-structuressecurity
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    simsen
    wrote on last edited by
    #1

    Hi, I have made a treeview, wich expand, when I remove the code: root.NavigateUrl = "Default.aspx?id=" + ParentNode[loop, 0]; BUT I have to know, what Id (which node in the treeview the user select), to give the right input from the database. I have stroggeld with this issue in many days now, but I still don't know what I shall do, so that when I redirect to Default, that it expand the treeview on that node, the user selected. Please can anybody help me? My Code: using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; public partial class _Default : System.Web.UI.Page { private OleDbConnection connection = null; public OleDbCommand command = null; public string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Inetpub\\wwwroot\\Test\\Menu3\\menu.mdb;"; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { fill_Tree(); } } void fill_Tree() { /* * Fill the treeview control Root Nodes From Parent Table * and child nodes from ChildTables */ connection = new OleDbConnection(connectionString); connection.Open(); /* * Query the database */ command = new OleDbCommand(); command.Connection = connection; DataTable myDataTable = new DataTable(); myDataTable.Columns.Add(new DataColumn("CategoryID", Type.GetType("System.String"))); myDataTable.Columns.Add(new DataColumn("ParentCategoryID", Type.GetType("System.String"))); myDataTable.Columns.Add(new DataColumn("CategoryName", Type.GetType("System.String"))); command.CommandText = "SELECT * FROM CATEGORIES WHERE ParentCategoryID = 0"; command.Parameters.Clear(); /* *Define and Populate the SQL DataReader */ OleDbDataReader myReader = command.ExecuteReader(); /* * Dispose the SQL Command to release resources */ command.Dispose(); /* * Initialize the string ParentNode. * We are going to populate this string array with our ParentTable Records * and then we will use this string array to populate our TreeView1 Control with parent record

    P 1 Reply Last reply
    0
    • S simsen

      Hi, I have made a treeview, wich expand, when I remove the code: root.NavigateUrl = "Default.aspx?id=" + ParentNode[loop, 0]; BUT I have to know, what Id (which node in the treeview the user select), to give the right input from the database. I have stroggeld with this issue in many days now, but I still don't know what I shall do, so that when I redirect to Default, that it expand the treeview on that node, the user selected. Please can anybody help me? My Code: using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.OleDb; public partial class _Default : System.Web.UI.Page { private OleDbConnection connection = null; public OleDbCommand command = null; public string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Inetpub\\wwwroot\\Test\\Menu3\\menu.mdb;"; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { fill_Tree(); } } void fill_Tree() { /* * Fill the treeview control Root Nodes From Parent Table * and child nodes from ChildTables */ connection = new OleDbConnection(connectionString); connection.Open(); /* * Query the database */ command = new OleDbCommand(); command.Connection = connection; DataTable myDataTable = new DataTable(); myDataTable.Columns.Add(new DataColumn("CategoryID", Type.GetType("System.String"))); myDataTable.Columns.Add(new DataColumn("ParentCategoryID", Type.GetType("System.String"))); myDataTable.Columns.Add(new DataColumn("CategoryName", Type.GetType("System.String"))); command.CommandText = "SELECT * FROM CATEGORIES WHERE ParentCategoryID = 0"; command.Parameters.Clear(); /* *Define and Populate the SQL DataReader */ OleDbDataReader myReader = command.ExecuteReader(); /* * Dispose the SQL Command to release resources */ command.Dispose(); /* * Initialize the string ParentNode. * We are going to populate this string array with our ParentTable Records * and then we will use this string array to populate our TreeView1 Control with parent record

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      Try this.............. When u click on node. Get the selected noe and save in session variable. when page is postback then check in session is not null then expand the selected node which store in session variable. otherwise do nothing. if u'r problem is different plz clerify here.

      Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com

      S 1 Reply Last reply
      0
      • P Parwej Ahamad

        Try this.............. When u click on node. Get the selected noe and save in session variable. when page is postback then check in session is not null then expand the selected node which store in session variable. otherwise do nothing. if u'r problem is different plz clerify here.

        Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com

        S Offline
        S Offline
        simsen
        wrote on last edited by
        #3

        Hi Parwej, Please can you give me som example code. I am a newbee, so I am a little lost in what you write to me Kind regards, simsen :-)

        P 1 Reply Last reply
        0
        • S simsen

          Hi Parwej, Please can you give me som example code. I am a newbee, so I am a little lost in what you write to me Kind regards, simsen :-)

          P Offline
          P Offline
          Parwej Ahamad
          wrote on last edited by
          #4

          Plz find this url............ http://www.15seconds.com/issue/041117.htm

          Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com

          S 1 Reply Last reply
          0
          • P Parwej Ahamad

            Plz find this url............ http://www.15seconds.com/issue/041117.htm

            Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com

            S Offline
            S Offline
            simsen
            wrote on last edited by
            #5

            Hi Parwej I am sorry, but I cannot see, what this helps me? I tried to use that code instead of my own. There is severel things here...... It don't expand/collapse when I click on the text (I don't want the arrows or other things - only text from my database). I want it so, if I click on the text, it shall redirect to the same page, but with the id for the specific entry, I clicked on in the url, and it shall expand the tree again (after redirecting) so the same id is selected. Like this: Home Products ...Cars ...Phones ...Laptops Company ...Who we are ...Our location Now when I load the site, it should look like this: Home Products Company When I click on Products it should redirect to the same site where in the url now instead of http://wwww.mypage.com/Default.aspx now sais http://www.mypage.com/Default.aspx?id=2 AND the menu should look like this: Home Products ...Cars ...Phones ...Laptops Company and so on.... Whith my first code, I could do everything .... only it don't expand the menu where I clicked..... Can you please help me with this? Kind regards, simsen :-)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups