DataList Bug

G

Guest

I dont know really know if this is a bug or not.
In my webform I hav
Header( User control
DataLis
Footer(User Control

The Header User Control has a Place Holder to which menu(another user control) is added dynamically based on the user role. (I have 3 menus for each role, and an appropriate menu is loaded based on the user logged in.
private void Page_Load(object sender, System.EventArgs e

/
Dynamically load the menu based on the user type
*
System.Web.UI.Control uc=null
if(HttpContext.Current.User.IsInRole("author")

uc=Page.LoadControl("~/UserControls/AuthorMenu.ascx")

else if(HttpContext.Current.User.IsInRole("reviewer")

uc=Page.LoadControl("~/UserControls/RevMenu.ascx")

else if(HttpContext.Current.User.IsInRole("planner")

uc=Page.LoadControl("~/UserControls/PlannerMenu.ascx")

else if(HttpContext.Current.User.IsInRole("planner")

uc=Page.LoadControl("~/UserControls/AdminMenu.ascx")

PlaceHolder1.Controls.Add(uc); //Source of the problem...


Problem
I have item template and edit templates in the datalist control
when I click the edit button in the item template the whole datalist control disappears on post back
I struggled for 2 days to zero in the source of the problem and finally found it

The problem arises if I add the dynamically loaded control(menu) to the placeholder in the header user control. If I comment that part out, everything works fine. Should I take this for a bug in .net or am I doing something wrong
Please hel
Kode.
 
A

Alvin Bruney [MVP]

Your post went unanswered. Have you resolved this issue? If you still need
help, please post the original question with your request.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Kode said:
I dont know really know if this is a bug or not.
In my webform I have
Header( User control)
DataList
Footer(User Control)

The Header User Control has a Place Holder to which menu(another user
control) is added dynamically based on the user role. (I have 3 menus for
each role, and an appropriate menu is loaded based on the user logged in.)
private void Page_Load(object sender, System.EventArgs e)
{
/*
Dynamically load the menu based on the user type.
*/
System.Web.UI.Control uc=null;
if(HttpContext.Current.User.IsInRole("author"))
{
uc=Page.LoadControl("~/UserControls/AuthorMenu.ascx");
}
else if(HttpContext.Current.User.IsInRole("reviewer"))
{
uc=Page.LoadControl("~/UserControls/RevMenu.ascx");
}
else if(HttpContext.Current.User.IsInRole("planner"))
{
uc=Page.LoadControl("~/UserControls/PlannerMenu.ascx");
}
else if(HttpContext.Current.User.IsInRole("planner"))
{
uc=Page.LoadControl("~/UserControls/AdminMenu.ascx");
}
PlaceHolder1.Controls.Add(uc); //Source of the problem...
}

Problem:
I have item template and edit templates in the datalist control.
when I click the edit button in the item template the whole datalist
control disappears on post back.
I struggled for 2 days to zero in the source of the problem and finally found it.

The problem arises if I add the dynamically loaded control(menu) to the
placeholder in the header user control. If I comment that part out,
everything works fine. Should I take this for a bug in .net or am I doing
something wrong.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top