Click here to Skip to main content
13,150,472 members (35,031 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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)
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));
        NavigationMenu.DataSource = liste; NavigationMenu.DataBind();

<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal">
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
                        <asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>

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
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.

1 solution

Rate this: bad
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[^]

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 |
Web04 | 2.8.170924.2 | Last Updated 16 Jan 2013
Copyright © CodeProject, 1999-2017
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