views:

16

answers:

0

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 menu 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?