This dynamic category navigation is in use at www.tire.biz when you click on "Vehicles".
I did it using the following DataList code:
<div id="submenuVehicles" class="anylinkcsscols">
<div class="column" id="columnVehicle">
<b>Vehicle Makes</b>
<asp:DataList ID="dlVehicleSubCategories" runat="server" RepeatColumns="4" RepeatDirection="Vertical"
RepeatLayout="Table" OnItemDataBound="dlVehicleSubCategories_ItemDataBound">
<ItemTemplate>
<asp:HyperLink ID="hlCategory" runat="server" />
</ItemTemplate>
</asp:DataList>
</div>
</div>
This relies on the anylinkcss menuing javascript library -
Get it hereand the following codebehind
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using NopSolutions.NopCommerce.BusinessLogic;
using NopSolutions.NopCommerce.BusinessLogic.Categories;
using NopSolutions.NopCommerce.BusinessLogic.SEO;
using NopSolutions.NopCommerce.Common.Utils;
namespace NopSolutions.NopCommerce.Web.Modules
{
public partial class MenuLeft : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindData();
}
}
protected void BindData()
{
int VehicleCategoryID = 7;
var vehicleCategoryCollection = CategoryManager.GetAllCategories(VehicleCategoryID);
if (vehicleCategoryCollection.Count > 0)
{
dlVehicleSubCategories.DataSource = vehicleCategoryCollection;
dlVehicleSubCategories.DataBind();
}
else
dlVehicleSubCategories.Visible = false;
}
protected void dlVehicleSubCategories_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
var category = e.Item.DataItem as Category;
string categoryURL = SEOHelper.GetCategoryURL(category.CategoryID);
var hlCategory = e.Item.FindControl("hlCategory") as HyperLink;
if (hlCategory != null)
{
hlCategory.NavigateUrl = categoryURL;
hlCategory.Text = Server.HtmlEncode(category.Name);
}
}
}
}
}
I hope that's helpful to you.
Jared Nielsen
www.FUZION.org