1114 CHAPTER 23 Using Site Maps DataRow[] results = (“ParentId=” + ); foreach (DataRow row in results) { SiteMapNode node = new SiteMapNode(this, row[“Id”].ToString(), row[“url”].ToString(), row[“title”].ToString(), row[“description”].ToString()); AddNode(node, parentNode); BuildSiteMapRecurse(siteMapTable, node); } } } } Like the custom Site Map provider that was created in the previous section, the SqlSiteMapProvider derives from the base StaticSiteMapProvider class. The SqlSiteMapProvider class overrides three methods of the base class: Initialize(), GetRootNodeCore(), and BuildSiteMap(). The Initialize() method retrieves a database connection string from the web configuration file. If a database connection string cannot be retrieved, the method throws a big, fat exception. Almost all the work happens in. | 1114 CHAPTER 23 Using Site Maps DataRow results ParentId foreach DataRow row in results SiteMapNode node new SiteMapNode this row Id .ToString row url .ToString row title .ToString row description .ToString AddNode node parentNode BuildSiteMapRecurse siteMapTable node Like the custom Site Map provider that was created in the previous section the SqlSiteMapProvider derives from the base StaticSiteMapProvider class. The SqlSiteMapProvider class overrides three methods of the base class Initialize GetRootNodeCore and BuildSiteMap . The Initialize method retrieves a database connection string from the web configuration file. If a database connection string cannot be retrieved the method throws a big fat exception. Almost all the work happens in the BuildSiteMap method. This method loads the contents of the SiteMap database table into an DataTable. Next it recursively builds the Site Map nodes from the DataTable. There is one special aspect of the code in Listing . It uses a SQL cache dependency to automatically rebuild the Site Map when the contents of the SiteMap database table are changed. To enable SQL cache dependencies for a database you must configure the database with either the enableNotifications tool or the aspnet_regsql tool. Use the enableNotifications tool when enabling SQL cache dependencies for a SQL Express database table and use the aspnet_regsql tool when enabling SQL cache dependencies for the full version of Microsoft SQL Server. NOTE To learn more about configuring SQL cache dependencies see Chapter 29 Caching Application Pages and Data. To enable SQL cache dependencies for a SQL Express database named SiteMapDB that contains a table named SiteMap browse to the folder that contains the file and execute the following command from a Command Prompt enableNotifications SiteMap From the Library of Wow eBook Creating Custom Site Map Providers 1115 You can configure your website .