Expand TreeView when redirect
-
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
-
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
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
-
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
-
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 :-)
Plz find this url............ http://www.15seconds.com/issue/041117.htm
Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com
-
Plz find this url............ http://www.15seconds.com/issue/041117.htm
Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com
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 :-)