Hello fellows,
My question is simplified as bellow:
1) A menu page has a menu with submenus. some of the submenu items links to page B which has a go back button links back to manu page.That means, Menu page <--> page B.
2) Page B need to change some components in it according to which submenu item leads it to Page B from menu page, ie., different page components according to different menu item clicked of menu page. That means, Page B = {Components} = diff(menu items)
3) The menu is constructed with data from a database table. I dont like to use XML file or so.
4) The page_load() function has lines as bellow:
01.if (!Page.IsPostBack)
02. {
03. String mySel = "select ..... desc";
04. SqlConnection conn = new SqlConnection(SqlDataSource1.ConnectionString);
05. SqlDataAdapter SQLDA = new SqlDataAdapter(mySel, conn);
06. conn.Open();
07. SqlDataReader SQLDR = SQLDA.SelectCommand.ExecuteReader();
08. Menu1.Items.Clear();
09. this.Menu1.Orientation = Orientation.Horizontal;
10. String GM;
11. while (SQLDR.Read())
12. {
13. GM = SQLDR["menuitem"].ToString();
14. MenuItem mi = new MenuItem();
15. mi.Text = GM;
16. String mySel2 = "select .....";
17. SqlConnection conn2 = new SqlConnection(SqlDataSource1.ConnectionString);
18. SqlDataAdapter SQLDA2 = new SqlDataAdapter(mySel2, conn2);
19. conn2.Open();
20. SqlDataReader SQLDR2 = SQLDA2.SelectCommand.ExecuteReader();
21. while (SQLDR2.Read())
22. {
23. MenuItem mii = new MenuItem();
24. mii.Text = SQLDR2["menusubitems"].ToString();
25.
26.
27.
28.
29. mii.Value = SQLDR2["url"].ToString();
30. mii.Selectable = true;
31. mi.ChildItems.Add(mii);
32. }
33. mi.Selectable = true;
34. this.Menu1.Items.Add(mi);
35. SQLDR2.Close();
36. conn2.Close();
37. };
38.
39. this.Menu1.Dispose();
40. SQLDR.Close();
41. conn.Close();
42.
43. }
44. }
if I didnot put " if(!Page.IsPostBack) " there, the menuitemclick event could not be reached. if I put " if(!Page.IsPostBack) " there, the event could be reached, but after getting to the new page from the menuitemclick event handle function through redirect(url), when it go back to the menu page, the menu disappears.
I got no ideas at all!