質問

がんのリピーターがすべてリスト web.sitemap 子どもたペー ASP.NET ページです。その DataSourceSiteMapNodeCollection.でも、た登録フォームのページにあります。

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:"コレクションを読み取りのみ"になります。

だからノードを削除したり前にコレクションDataBindingのリピーター?

役に立ちましたか?

解決

おな要CType

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

他のヒント

使用Linqます。純3.5:

//this will now be an enumeration, rather than a read only collection
Dim children = SiteMap.CurrentNode.ChildNodes.Where( _
    Function (x) x.Url <> "/Registration.aspx" )

RepeaterSubordinatePages.DataSource = children 

なLinqです。純2:

Function IsShown( n as SiteMapNode ) as Boolean
    Return n.Url <> "/Registration.aspx"
End Function

...

//get a generic list
Dim children as List(Of SiteMapNode) = _
    New List(Of SiteMapNode) ( SiteMap.CurrentNode.ChildNodes )

//use the generic list's FindAll method
RepeaterSubordinatePages.DataSource = children.FindAll( IsShown )

防除項目のメントシステム開発を支援しています。ないというループを複数回だけないほうがよい。

物価が高いというのは意外でした仕事を以下のコード:

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

がより良い方法が思っていたの CType()?

また、このセットも System.Collections.Generic.IEnumerable(Of Object).いい方法はありませんかかのように強く型付けされたように System.Collections.Generic.IEnumerable(Of System.Web.SiteMapNode) でも、 System.Web.SiteMapNodeCollection?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top