How can I remove nodes from a SiteMapNodeCollection?

前端 未结 3 1499
清歌不尽
清歌不尽 2021-01-24 09:14

I\'ve got a Repeater that lists all the web.sitemap child pages on an ASP.NET page. Its DataSource is a SiteMapNodeCollection. But, I do

3条回答
  •  粉色の甜心
    2021-01-24 10:00

    I got it to work with code below:

    Dim children = From n In SiteMap.CurrentNode.ChildNodes _
                   Where CType(n, SiteMapNode).Url <> "/Registration.aspx" _
                   Select n
    RepeaterSubordinatePages.DataSource = children
    

    Is there a better way where I don't have to use the CType()?

    Also, this sets children to a System.Collections.Generic.IEnumerable(Of Object). Is there a good way to get back something more strongly typed like a System.Collections.Generic.IEnumerable(Of System.Web.SiteMapNode) or even better a System.Web.SiteMapNodeCollection?

提交回复
热议问题