How do i do a loop

Posts   
 
    
davidbni
User
Posts: 1
Joined: 08-Dec-2011
# Posted on: 08-Dec-2011 13:47:37   

I am using the new routing feature of asp.net to create friendly urls I have these stored in a table cms and create a llblgen entity how do i go about loop this entity t get the friendly urls out

then i want to build this dymically // Register a route for Products/{ProductName} routes.MapPageRoute( "Shop", // Route name "{ShoppingCart}", // Route URL "~/Basket.aspx" // Web page to handle route

regards david buckley wsi developer

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Dec-2011 20:08:36   

Well, suppose you the entity is called MyRoutes and that you are using Adapter template set, then it could be something like (approx code:

// fetch myRoutes
var myRoutes = new EntityCollection<MyRouteEntity>();
using (var adapter = new DataAccessAdapter())
{
     adapter.FetchEntityCollection(myRoutes, null);
}

     // add routes
foreach(var r in myRoutes)
{
     routes.MapPageRoute(
            r.RouteName,
            string.Format("\{{0}\}", r.DisplayName),
            string.Format("~/{0}.aspx", r.Url) );
}
David Elizondo | LLBLGen Support Team