sumisudhakar 0 Newbie Poster

I am currently working in an ASP.Net application where i need to implement ASP.Net Membership and Roles. I have used Login controls in my pages.
Also I am using a menu in the master page, which is getting data bindings from database. For data bindings I am using XMLDatasource and a transform file (.xslt file).
I need to bind the data to the Menu based on the user roles.

My issue is that the generated Menu is not behaving consistently. Sometimes it will show the correct menu for a particular role and some times it will show previously loaded data.

Providing my code here:


private void LoadMenuItems() {

System.Security.Principal.IPrincipal User;

User = System.Web.HttpContext.Current.User; 

string appName = HttpContext.Current.Request.ApplicationPath;
string username = User.Identity.Name;

DataSet menuSet = new DataSet();  

xmlDataSource.Data = null;

menuSet = GetMenuDetails(appName, username);

menuSet.DataSetName = "Menus";

menuSet.Tables[0].TableName = "Menu"; 

DataRelation relation = new DataRelation("ParentChild",

relation.Nested = menuSet.Relations.Add(relation);

xmlDataSource.Data = menuSet.GetXml();

Masterpage Source:

<asp:Menu ID="Menu2" runat="server" Width="200px" DataSourceID="xmlDataSource">
                            <asp:MenuItemBinding DataMember="MenuItem" NavigateUrlField="NavigateUrl" TextField="Text"
                                ToolTipField="ToolTip" />
<asp xmlDataSource ID="xmlDataSource" TransformFile="~/MenuFile.xslt" XPath="MenuItems/MenuItem"
                        runat="server"></asp XmlDataSource>

Please help me to fix this issue.
Thanking You.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.