0
Answer

WebParts

Hi All, I m new to this forum. i m working on web parts now. Please help me out... I am loading user controls referred from DB for each user as per requirement. i m able to add the controls , but i m not able to personalize these dynamically added contents. I tried doing with catalog manager but i want to display the usercontrols for a particular user from DB in Pageload itself. if i use catalog manager, the user shud select the usercontrols. this is the code which i have tried: dsusercntrl is the dataset refering to my usercontrol path AddControlsZone is the zone in my aspx page. if (dsusercntrl.Tables[0].Rows.Count != 0) { for (int i = 0; i < dsusercntrl.Tables[0].Rows.Count; i++) { string strUserControlPath = dsusercntrl.Tables[0].Rows[i]["UserControlPath"].ToString(); Control ucdet = this.LoadControl(strUserControlPath); ucdet.ID = dsusercntrl.Tables[0].Rows[i]["UseControlName"].ToString(); string[] str = strUserControlPath.Split('/'); int inturlcount = str.Length; string strcntrlname = str[inturlcount - 1]; strcntrlname = "controls_" + strcntrlname.Replace('.', '_').ToLower(); if (AddControlsZone.WebParts.Count > 0) { WebPart webccontrol = AddControlsZone.WebParts[0]; //int intwebcount = AddControlsZone.WebParts.Count; //int intcntrlcount = AddControlsZone.Controls.Count; if (dsusercntrl.Tables[0].Rows.Count == AddControlsZone.WebParts.Count) { HttpCookie cookEmail = new HttpCookie("Email", EmailID); Response.Cookies.Remove("Email"); Response.Cookies.Add(cookEmail); HttpCookie cookPass = new HttpCookie("Pass", Password); Response.Cookies.Remove("Pass"); Response.Cookies.Add(cookPass); Response.Cookies["Email"].Expires = DateTime.Now.AddDays(15); Response.Cookies["Pass"].Expires = DateTime.Now.AddDays(15); } else { GenericWebPart wpdet = WebPartmngr.CreateWebPart(ucdet); wpdet.Title = dsusercntrl.Tables[0].Rows[i]["UseControlName"].ToString(); WebPartmngr.AddWebPart(wpdet, AddControlsZone, 1); } } else { GenericWebPart wpdet = WebPartmngr.CreateWebPart(ucdet); wpdet.Title = dsusercntrl.Tables[0].Rows[i]["UseControlName"].ToString(); WebPartmngr.AddWebPart(wpdet, AddControlsZone, 1); } } } }