Search code examples
user-controlsc1-cms

Accessing Page datafolder data from C#


I defined a Page datafolder in the Data view and created data for one of my pages.

How can I access this data from an ASP.NET usercontrol placed on the page?


Solution

  • Here is a small code sample for getting page folder data for a given page folder type. Change the type Martin.MyPageFolder to your type and it should work just fine.

    using (DataConnection connection = new DataConnection())
    {
      var pageFolderData = 
        from d in connection.Get<Martin.MyPageFolder>()
        where d.PageId == SitemapNavigator.CurrentPageId
        select d;
    
      foreach (var item in pageFolderData)
      {
        // Use the item here as you need
      }             
    }