SiteMapNodeItem(Int32, SiteMapNodeItemType) 생성자

정의

지정된 인덱스 및 SiteMapNodeItem을 사용하여 SiteMapNodeItemType 클래스의 새 인스턴스를 초기화합니다.

public:
 SiteMapNodeItem(int itemIndex, System::Web::UI::WebControls::SiteMapNodeItemType itemType);
public SiteMapNodeItem (int itemIndex, System.Web.UI.WebControls.SiteMapNodeItemType itemType);
new System.Web.UI.WebControls.SiteMapNodeItem : int * System.Web.UI.WebControls.SiteMapNodeItemType -> System.Web.UI.WebControls.SiteMapNodeItem
Public Sub New (itemIndex As Integer, itemType As SiteMapNodeItemType)

매개 변수

itemIndex
Int32

Controls 컨트롤에서 SiteMapPath 개체를 추적하기 위해 사용하는 SiteMapNodeItem 컬렉션의 인덱스입니다.

itemType
SiteMapNodeItemType

SiteMapNode이 나타내는 SiteMapNodeItem의 기능적 유형입니다.

예제

다음 코드 예제에는 만드는 방법을 보여 줍니다는 SiteMapNodeItem 개체입니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 SiteMapPath 클래스입니다.

private void AddDropDownListAfterCurrentNode(SiteMapNodeItem item) {

    SiteMapNodeCollection childNodes = item.SiteMapNode.ChildNodes;

    // Only do this work if there are child nodes.
    if (childNodes != null) {

        // Add another PathSeparator after the CurrentNode.
        SiteMapNodeItem finalSeparator =
            new SiteMapNodeItem(item.ItemIndex,
                                SiteMapNodeItemType.PathSeparator);

        SiteMapNodeItemEventArgs eventArgs =
            new SiteMapNodeItemEventArgs(finalSeparator);

        InitializeItem(finalSeparator);
        // Call OnItemCreated every time a SiteMapNodeItem is
        // created and initialized.
        OnItemCreated(eventArgs);

        // The pathSeparator does not bind to any SiteMapNode, so
        // do not call DataBind on the SiteMapNodeItem.
        item.Controls.Add(finalSeparator);

        // Create a DropDownList and populate it with the children of the
        // CurrentNode. There are no styles or templates that are applied
        // to the DropDownList control. If OnSelectedIndexChanged is raised,
        // the event handler redirects to the page selected.
        // The CurrentNode has child nodes.
        DropDownList ddList = new DropDownList();
        ddList.AutoPostBack = true;

        ddList.SelectedIndexChanged += new EventHandler(this.DropDownNavPathEventHandler);

        // Add a ListItem to the DropDownList for every node in the
        // SiteMapNodes collection.
        foreach (SiteMapNode node in childNodes) {
            ddList.Items.Add(new ListItem(node.Title, node.Url));
        }

        item.Controls.Add(ddList);
    }
}
Private Sub AddDropDownListAfterCurrentNode(item As SiteMapNodeItem)

   Dim childNodes As SiteMapNodeCollection = item.SiteMapNode.ChildNodes

   ' Only do this work if there are child nodes.
   If Not (childNodes Is Nothing) Then

      ' Add another PathSeparator after the CurrentNode.
      Dim finalSeparator As New SiteMapNodeItem(item.ItemIndex, SiteMapNodeItemType.PathSeparator)

      Dim eventArgs As New SiteMapNodeItemEventArgs(finalSeparator)

      InitializeItem(finalSeparator)
      ' Call OnItemCreated every time a SiteMapNodeItem is
      ' created and initialized.
      OnItemCreated(eventArgs)

      ' The pathSeparator does not bind to any SiteMapNode, so
      ' do not call DataBind on the SiteMapNodeItem.
      item.Controls.Add(finalSeparator)

      ' Create a DropDownList and populate it with the children of the
      ' CurrentNode. There are no styles or templates that are applied
      ' to the DropDownList control. If OnSelectedIndexChanged is raised,
      ' the event handler redirects to the page selected.
      ' The CurrentNode has child nodes.
      Dim ddList As New DropDownList()
      ddList.AutoPostBack = True

      AddHandler ddList.SelectedIndexChanged, AddressOf Me.DropDownNavPathEventHandler

      ' Add a ListItem to the DropDownList for every node in the
      ' SiteMapNodes collection.
      Dim node As SiteMapNode
      For Each node In  childNodes
         ddList.Items.Add(New ListItem(node.Title, node.Url))
      Next node

      item.Controls.Add(ddList)
   End If
End Sub

설명

경우는 PathDirection 됩니다 RootToCurrent, 사이트 탐색 계층의 각 하위 수준 항목 끝에 추가할 수 있습니다는 Controls 컬렉션입니다. 그러나 경우는 PathDirection 속성이로 설정 되어 CurrentToRoot, 시작 부분에 각 하위 수준 노드를 삽입 해야는 Controls 컬렉션입니다.

적용 대상

추가 정보