Tuesday, March 13, 2012

SiteMapPath Question

Hello,

I am having a little difficulty coming up with a solution for the
following requirement and I was hoping somebody might be able to offer
some help. I need to create a SiteMapPath for a category system that
supports any number of nested categories. Here's what I mean:

Category A
Category B
Category C
Category D
Category E

This information is stored in a single Categories table in my database
and looks like this:

Id ParentId Name
----------------
1 NULL Category A
2 1 Category B
3 2 Category C
4 NULL Category D
5 4 Category E

If the user was on the details page for Category C, the SiteMapPath
should display Home Category A Category B Category C and the user
should be able the backtrack through the nested structure.

I know that I can create a custom SiteMapProvider that can use a
database as its data source, but I am not sure if this is the right
way. Any feedback would be highly appreciated. Thanks!In article <1155763320.269593.147640@.m73g2000cwd.googlegroups. com>,
sean.marchetti@.gmail.com writes

Quote:

Originally Posted by

>Hello,
>
>I am having a little difficulty coming up with a solution for the
>following requirement and I was hoping somebody might be able to offer
>some help. I need to create a SiteMapPath for a category system that
>supports any number of nested categories. Here's what I mean:
>
>Category A
Category B
Category C
>Category D
Category E
>
>This information is stored in a single Categories table in my database
>and looks like this:
>
>Id ParentId Name
>----------------
>1 NULL Category A
>2 1 Category B
>3 2 Category C
>4 NULL Category D
>5 4 Category E
>
>If the user was on the details page for Category C, the SiteMapPath
>should display Home Category A Category B Category C and the user
>should be able the backtrack through the nested structure.
>
>I know that I can create a custom SiteMapProvider that can use a
>database as its data source, but I am not sure if this is the right
>way. Any feedback would be highly appreciated. Thanks!


I did something very similar to this. What I did was that every time the
database was changed, I wrote out a categories.sitemap file (the format
is very simple) and then used a standard sitemappath control in the
..aspx file. Worked a treat and avoided database hits every time.

HTH

--
Alan Silver
(anything added below this line is nothing to do with me)

0 comments:

Post a Comment