开发者

Programmatically Set Asp Menu to Selected

I dynamically populate my Asp.Net Menu based on my Database:

public class BasicHyperLink {
    public string Title { get; set; }
    public string Url { get; set; }
}

// For example, for the first menu
// This is under mnu_DataBound:
MenuItem parentItem = mnu.Items[0]; // Get first men开发者_Go百科u item

foreach (BasicHyperLink link in getLinksListFromDB( 0 )) {
   parentItem.ChildItems.Add( new MenuItem(link.Title, "", "", link.Url));
}

However, when these dynamic links are clicked, the Asp.Net Menu Adapter doesn't resolve and set these as the current page. If they're hard-coded, there's no problem.

I'm using CSS Friendly Adapters.

Is there a method I can call after the Menu is DataBound to check the items in the menu and set the correct CSS Class?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜