Click here to Skip to main content
12,507,343 members (74,308 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
Hi,
i want to show different menu for different users but dont show menu

for example a users show only home page in menu
b users show about page and home page in menu
c user show only about page in menu


I have 3 tables in databases

1. Kullanıcılar[in english users] (username(PK) ve userpassword fields)

2. Menuler (MenuId(PK),SayfaAdi ve SayfaLink[In english PageLink] fields)

3. KullaniciMenu(username ve menuid fields)
---------------
public class MenuBilgi
{
    private string sayfaAdi;
    private string sayfaLink;
 
    public string SayfaLink
    {
        get { return sayfaLink; }
        set { sayfaLink = value; }
    }
    public string SayfaAdi
    {
        get { return sayfaAdi; }
        set { sayfaAdi = value; }
    }
    public MenuBilgi(string sayfaAdi, string sayfaLink)
    {
        this.sayfaAdi = sayfaAdi;
        this.sayfaLink = sayfaLink;
    }
}
--------------------------------------------
aLTER proc [dbo].[MenuGetir]
(
@Username nvarchar(15)
)
as
select SayfaAdi,SayfaLink from Menuler inner join KullaniciMenu on Menuler.MenuId=Kullanici.MenuId where KullaniciMenu.Username=@Username
------------------------------------
public partial class SiteMaster : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
        SqlParameter[] paramdizi = new SqlParameter[1]
 
            {
               new SqlParameter("@UserName",SqlDbType.NVarChar)
            };
 
        paramdizi[0].Value = Session["Username"];
 
        Baglanti baglanti = new Baglanti();
 
        SqlDataReader dr = baglanti.ExecuteReader("MenuGetir", CommandType.StoredProcedure, paramdizi);
 
        List<MenuBilgi> liste = new List<MenuBilgi>();
 
        while (dr.Read())
        {
            MenuBilgi bilgi = new MenuBilgi(dr.GetString(0), dr.GetString(1));
            liste.Add(bilgi);
        }
 
        NavigationMenu.DataSource = liste; NavigationMenu.DataBind();
    }
}
-------------------------------------
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
                        <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
                    </Items>
 
               </asp:Menu>
But navigationmenu.datasource=liste; >>> THİS ERROR MESAJ: HierrarhicalDataBoundControl only accept datasources that implement HierarchicalDataSource or HierarchicalEnumerable.

help pls
Posted 15-Jan-13 7:18am
Updated 15-Jan-13 7:32am
v2
Comments
   
Please don't post non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership.
Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.
—SA

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You need to set your datasource with any implemented by IHierarchyData.
Check this article, i hope it will help you.
Implementing IHierarchy Support Into Your Custom Collections[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160927.1 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100