Pass argument to GetDynamicNodeCollection

Jan 31, 2011 at 4:36 PM

I was wondering if it would be possible to pass some parameters to the GetDynamicNodeCollection.

I've got a single table that is used to generate category information, so it seems silly to extend the base provider for every category classification.

Ideally I would like to pass in a parentID value and generate the Node List with all children matching parentID

Jan 31, 2011 at 8:09 PM

So I've got myself completely confused now.

I'm trying to implement a DynamicNodeProvider for parts of the SiteMap.

If I just manually create a few and add them, things work fine.

public class HomeListDynamicNodeProvider : DynamicNodeProviderBase
  public override IEnumerable<DynamicNode>    
    var returnValue = new List<DynamicNode>();
    DynamicNode node = new DynamicNode("Test1", "First Test");
    node.RouteValues.Add("testers", "First Test");

    node = new DynamicNode("Test2", "Second Test");
    node.RouteValues.Add("testers", "Second Test");

    return returnValue;

Adding this anywhere in my sitemap produces the desired results

<mvcSiteMapNode title="Testers" action="Testing" dynamicNodeProvider="nvpMVC.Code.HomeListDynamicNodeProvider, nvpMVC" />

However, if I pull data from the DB, I never get the nodes showing up.

public class LoadingTypeDynamicNodeProvider : DynamicNodeProviderBase
  EquipmentEntities equipmentDB = new EquipmentEntities();
  public override IEnumerable<DynamicNode>  GetDynamicNodeCollection()
      var load = from c1 in equipmentDB.Classifications
      where c1.name_en.Equals("Loading")
      join c2 in equipmentDB.Classifications on equals c2.parent_id
      select c2;

      foreach (var item in load)
          DynamicNode node = new DynamicNode("a_"+item.name_en, item.name_en);
          node.RouteValues.Add("a", item.name_en);
          yield return node;

Adding this to the Sitemap

<mvcSiteMapNode title="NoDeal" action="neverWorks"  dynamicNodeProvider="nvpMVC.Code.LoadingDynamicNodeProvider, nvpMVC" />

I never see anything show up where it should.

I'm completely stumped.

Feb 1, 2011 at 1:24 PM

Nevermind, my appologies.

I accidentally a filename....... >.<

Feb 4, 2011 at 10:31 AM

No problem :-)