/// <exception cref="SPSException"><c>SPSException</c>.</exception>
        protected override void CreateChildControls()
        {
            try
            {
                using (SPWeb web = SPContext.Current.Web.Site.OpenWeb())
                {
                    using (dataSource = new SPSHierarchyDataSource(web, GetList()))
                    {
                        dataSource.CacheService = CacheService;
                        SPSHierarchyFilter dataFilter = new SPSHierarchyFilter
                        {
                            IncludeFolders        = true,
                            IncludeNumberOfFiles  = ShowCounter,
                            IncludeWebs           = false,
                            IncludeLists          = false,
                            SortHierarchy         = _sortHierarchy,
                            HideUnderscoreFolders = HideUnderscoreFolders
                        };

                        if (!string.IsNullOrEmpty(Filter))
                        {
                            dataFilter.OnFilter += DataSourceFilter;
                        }

                        dataSource.Filter = dataFilter;

                        treeView             = SPSTreeViewHelper.MakeTreeView(dataSource, GenerateLinkForPath);
                        treeView.ExpandDepth = ExpandDepth;

                        Controls.Add(treeView);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new SPSException(ex.TargetSite.Name, ex);
            }
        }
        protected override void CreateChildControls()
        {
            using (SPWeb web = GetWebToUse())
            {
                try
                {
                    SPSHierarchyFilter dataFilter = new SPSHierarchyFilter
                    {
                        SortHierarchy  = true,
                        IncludeLists   = _showLists,
                        IncludeWebs    = _showSubSites,
                        IncludeFolders = _showFolders,
                        MaxDeepth      = 9999
                    };

                    if (!string.IsNullOrEmpty(FilterWeb) || !string.IsNullOrEmpty(FilterList))
                    {
                        dataFilter.OnFilter += DataSourceFilter;
                    }

                    using (SPSHierarchyDataSource dataSource = new SPSHierarchyDataSource(web))
                    {
                        dataSource.CacheService = GetCacheService();
                        dataSource.Filter       = dataFilter;

                        treeView             = SPSTreeViewHelper.MakeTreeView(dataSource, null);
                        treeView.ExpandDepth = ExpandDepth;

                        Controls.Add(treeView);
                    }
                }
                catch (Exception ex)
                {
                    ErrorMessage += ex.Message;
                }
            }
        }
Example #3
0
        /// <exception cref="SPException"><c>SPException</c>.</exception>
        protected override void CreateChildControls()
        {
            if (!string.IsNullOrEmpty(ListGuid))
            {
                try
                {
                    SPWeb web = SPContext.Current.Web;

                    using (dataSource = new SPSHierarchyDataSource(web, web.Lists[ListID]))
                    {
                        SPSHierarchyFilter dataFilter = new SPSHierarchyFilter
                        {
                            IncludeFolders       = true,
                            IncludeNumberOfFiles = true,
                            IncludeWebs          = false,
                            IncludeLists         = false,
                            SortHierarchy        = true
                        };

                        dataSource.Filter = dataFilter;

                        treeView = SPSTreeViewHelper.MakeTreeView(dataSource, null);

                        Controls.Add(treeView);
                    }
                }
                catch (Exception e)
                {
                    throw new SPException(
                              string.Format("Error: {0}\nMessage:{1}\nTrace:\n{2}",
                                            e.GetType(),
                                            e.Message,
                                            e));
                }
            }
        }