我怎样才能从SiteMapNodeCollection删除节点? [英] How can I remove nodes from a SiteMapNodeCollection?

查看:135
本文介绍了我怎样才能从SiteMapNodeCollection删除节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个中继器,列出ASP.NET页面上的所有的web.sitemap 子页面。它的数据源 SiteMapNodeCollection 。但是,我不希望我的注册表单页面展现在那里。

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 don't want my registration form page to show up there.

Dim Children As SiteMapNodeCollection = SiteMap.CurrentNode.ChildNodes

'remove registration page from collection
For Each n As SiteMapNode In SiteMap.CurrentNode.ChildNodes
If n.Url = "/Registration.aspx" Then
    Children.Remove(n)
End If
Next

RepeaterSubordinatePages.DataSource = Children

SiteMapNodeCollection.Remove()方法抛出

NotSupportedException异常:收藏是只读

NotSupportedException: "Collection is read-only".

我怎么能数据绑定的Repeater之前从集合节点?

How can I remove the node from the collection before DataBinding the Repeater?

推荐答案

您应该不需要CTYPE

Your shouldn't need CType

Dim children = _
    From n In SiteMap.CurrentNode.ChildNodes.Cast(Of SiteMapNode)() _
    Where n.Url <> "/Registration.aspx" _
    Select n

这篇关于我怎样才能从SiteMapNodeCollection删除节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆