By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,887 Members | 1,214 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,887 IT Pros & Developers. It's quick & easy.

problem with masterpages and tabs while dynamically creating controls

P: 30
My project is about jewellery. I have devided my jewelery into main types, which each one of them has sub types, and each one those sub types has the jewellery.

I have a tabcontainer. It includes tabpanels such as:Catalog,Terms,SiteMap.ViewCart ,etc. All the jewellery Intro is in the Catalog panel. when I first click the Catalog panel it Introduces me all the main types of the jewellery(It's all done dynamically from the cs file).The background has 2 regular empty panels in the both sides of the page. Then when you click any of those maintypes(which are linkbuttons) , i want the tabpanel to be updated and to show all the subtypes of that main type which you have clicked. iN ADDITION, I want the maintypes to appear in the right empty panel in the corner of the page - so the background is changed. (I remind you all this happens in the Catalog tabpanel). Then when you click on one of the subtypes links all the hewellery with the detalis and the images appear, and the panel in the corner still shows the main types! and all that still is in the Catalog panel. now look: when i click on other TablPanel, I want the panels that are in the corner to be empty again and not to show the main types.

There is another problem beacuse of which I really got confused:

I remind you that all the creation of the maintypes links, subtypes links and then the jewellery with the details, is all dynamically made through the code behind. I have tried to create the maintypes linkbuttons dynamically, and ofcourse added the click event and it worked. Cool. the problem is that in the click event of the maintype(which ias dynamically made) I ceate new linkbuttons and create their click events also dynamically of course. Here is the code:

Expand|Select|Wrap|Line Numbers
  1. public void MainTypeIntro(DataSet myDS, Panel p1) 
  2. {
  3.  
  4. string MainType = myDS.Tables[0].Rows[Num]["Jewel_Main_Type_Name"].ToString(); 
  5. LinkButton lb_main = new LinkButton();
  6.  
  7. lb_main.Style["Position"] = "Absolute"; 
  8. lb_main.Style["Top"] = "" + Top + "px";
  9.  
  10. lb_main.Style["Left"] = "" + Left + "px";lb_main.Style["color"] = "blue"; 
  11. lb_main.Text = MainType;
  12.  
  13. lb_main.ID = "lb" + Num.ToString(); 
  14. p1.Controls.Add(lb_main);
  15.  
  16. lb_main.Click += new EventHandler(lb_main_Click);
  17.  
  18. HttpContext.Current.Session["UN"] = UserName; 
  19. }
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. void lb_main_Click(object sender, EventArgs e) 
  28. {
  29.  
  30. LinkButton lb_Main = sender as LinkButton; 
  31. string MainType = lb_Main.Text;
  32.  
  33. string connstr = HttpContext.Current.Session["Connstr"].ToString(); 
  34. OleDbConnection myConn = new OleDbConnection(connstr);
  35.  
  36. string SqlGetSubByMain = "Select * from TBL_Jewel_Sub_Type where Jewel_Main_Type_ID=('" + MainType + "')"; 
  37. OleDbDataAdapter myAdapter = new OleDbDataAdapter(SqlGetSubByMain, myConn);
  38.  
  39. DataSet myDS = new DataSet(); 
  40. myAdapter.Fill(myDS);
  41.  
  42. HttpContext.Current.Session["MainType"] = lb_Main; 
  43. HttpContext.Current.Session["SubTypeByMainTypeDS"] = myDS;
  44.  
  45. if (lb_Main.ID != null) 
  46. {
  47.  
  48. HttpContext.Current.Response.Redirect("SubTypeIntro.aspx?UserName=" +HttpContext.Current.Session["UN"].ToString() + "&IsUserSigned=true"); 
  49. }
  50.  
  51. else HttpContext.Current.Response.Redirect("DeniedAccessForUnSignedCustomer.aspx"); 
  52. }
  53.  
  54.  
  55.  
  56. public void SubTypeIntro(DataSet myDS, Panel p1) 
  57. {
  58.  
  59. HttpContext.Current.Session["UN"] = UserName; 
  60. string SubType = myDS.Tables[0].Rows[Num]["Jewel_Sub_Type_Name"].ToString();
  61.  
  62. LinkButton lb_sub = new LinkButton(); 
  63. lb_sub.Style["Position"] = "Absolute";
  64.  
  65. lb_sub.Style["Top"] = "" + Top + "px"; 
  66. lb_sub.Style["Left"] = "" + Left + "px";
  67.  
  68. lb_sub.Style["color"] = "blue"; 
  69. lb_sub.Text = SubType;
  70.  
  71. p1.Controls.Add(lb_sub);
  72.  
  73. lb_sub.ID = "lb_" + int.Parse(myDS.Tables[0].Rows[Num]["Jewel_Sub_Type_ID"].ToString());lb_sub.Click += new EventHandler(lb_sub_Click); 
  74. }
  75.  
  76. void lb_sub_Click(object sender, EventArgs e) 
  77. {
  78.  
  79. string UserName = HttpContext.Current.Session["UN"].ToString();
  80.  
  81. LinkButton lb_sub = sender as LinkButton; 
  82. HttpContext.Current.Session["SubType"] = lb_sub;
  83.  
  84. string lb_id = lb_sub.ID; 
  85. int sub_id = int.Parse(lb_id.Remove(0, lb_id.IndexOf('_') + 1));
  86.  
  87. string connstr = HttpContext.Current.Session["Connstr"].ToString(); 
  88. System.Data.OleDb.OleDbConnection myConn = new System.Data.OleDb.OleDbConnection(connstr);
  89.  
  90. string all_name = "Select * from TBL_Jewel_Name where Jewel_Sub_Type_ID=" + sub_id + ""; 
  91. System.Data.OleDb.OleDbDataAdapter myAdapter_name = new System.Data.OleDb.OleDbDataAdapter(all_name, myConn);
  92.  
  93. System.Data.DataSet myDS_name = new System.Data.DataSet(); 
  94. myAdapter_name.Fill(myDS_name);
  95.  
  96. HttpContext.Current.Session["NameBySubTypeDS"] = myDS_name;HttpContext.Current.Response.Redirect("JewelIntro.aspx?UserName=" +UserName + "&IsUserSigned=true"); 
  97.  
  98.  
  99. }


What is the problem? The problem is that the whole thing is loaded in the page load- when you click the catalog tabpanel, and I followed the project while debugging and it skipped the subtype_click and didn't commit it... I have tried to solve this problem like this(I know it's a little hard to follow but please.. it's really important, and if something isn't clear tell me and i'll clarify my wish, thanks):

I created new aspx pages: SubTypeIntro.aspx and JewelIntro.aspx. There I set the same tabcontainer and etc.. and the Maintypes are shown in the "ORIGINAL ASPX" , then on the click event it goes to the SubTypeIntro page and there loads all the subtypes, and then on the subclick it goes to the JewelIntro Page... and there loads the jewels. It works greatlly and I have achieaved my target but it's very stupid in my opinion.. I use 2 masters for it and it's all really messed up.



As a conclusion: The main problem is how to solve the second problem without using the other pages and remaining in one aspx page in the same Catalog tabpanel.



If something isn't clear or if you got puzzled , please tell me and I will give you more details and even if you want my whole project. Please at least read my problems.. Anyway, THANK YOU for any kind of help or solutions... I don't know maybe my way is good but there is another one to arrange all that stuff.. So if you can help me somehow - It's my final project in ASP.NET in the highschool. Thanks.
Nov 17 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.