TreeNodeBindingCollection 클래스

정의

TreeView 컨트롤에 있는 TreeNodeBinding 개체의 컬렉션을 나타냅니다. 이 클래스는 상속될 수 없습니다.

public ref class TreeNodeBindingCollection sealed : System::Web::UI::StateManagedCollection
public sealed class TreeNodeBindingCollection : System.Web.UI.StateManagedCollection
type TreeNodeBindingCollection = class
    inherit StateManagedCollection
Public NotInheritable Class TreeNodeBindingCollection
Inherits StateManagedCollection
상속
TreeNodeBindingCollection

예제

이 섹션에는 두 코드 예제가 있습니다. 첫 번째 코드 예제에서는 채우는 방법을 보여 줍니다는 TreeNodeBindingCollection 선언적으로 개체입니다. 두 번째 코드 예제에서는 채우는 방법을 보여 줍니다는 TreeNodeBindingCollection 프로그래밍 방식으로 개체입니다.

다음 코드 예제에서는 채우는 방법을 보여 줍니다는 TreeNodeBindingCollection 선언적으로 개체입니다. 이 예제가 제대로 작동 하려면에 대 한 Book.xml 라는 파일에이 섹션의 끝에 있는 XML 데이터를 복사 해야 합니다.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeView XML Data Binding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView XML Data Binding Example</h3>
    
      <asp:TreeView id="BookTreeView" 
        DataSourceID="BookXmlDataSource"
        runat="server">
         
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Book" TextField="Title"/>
          <asp:TreeNodeBinding DataMember="Chapter" TextField="Heading"/>
          <asp:TreeNodeBinding DataMember="Section" TextField="Heading"/>
        </DataBindings>
         
      </asp:TreeView>

      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Book.xml"
        runat="server">
      </asp:XmlDataSource>
    
    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeView XML Data Binding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView XML Data Binding Example</h3>
    
      <asp:TreeView id="BookTreeView" 
        DataSourceID="BookXmlDataSource"
        runat="server">
         
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Book" TextField="Title"/>
          <asp:TreeNodeBinding DataMember="Chapter" TextField="Heading"/>
          <asp:TreeNodeBinding DataMember="Section" TextField="Heading"/>
        </DataBindings>
         
      </asp:TreeView>

      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Book.xml"
        runat="server">
      </asp:XmlDataSource>
    
    </form>
  </body>
</html>

다음 코드 예제에서는 채우는 방법을 보여 줍니다는 TreeNodeBindingCollection 프로그래밍 방식으로 개체입니다. 이 예제가 제대로 작동 하려면에 대 한 Book.xml 라는 파일에이 섹션의 끝에 있는 예제 XML 데이터를 복사 해야 합니다.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Page_Load(Object sender, EventArgs e)
  {

    // Create a new TreeView control.
    TreeView NewTree = new TreeView();

    // Set the properties of the TreeView control.
    NewTree.ID = "BookTreeView";
    NewTree.DataSourceID = "BookXmlDataSource";

    // Create the tree node binding relationship.

    // Create the root node binding.
    TreeNodeBinding RootBinding = new TreeNodeBinding();
    RootBinding.DataMember = "Book";
    RootBinding.TextField = "Title";

    // Create the parent node binding.
    TreeNodeBinding ParentBinding = new TreeNodeBinding();
    ParentBinding.DataMember = "Chapter";
    ParentBinding.TextField = "Heading";

    // Create the leaf node binding.
    TreeNodeBinding LeafBinding = new TreeNodeBinding();
    LeafBinding.DataMember = "Section";
    LeafBinding.TextField = "Heading";

    // Add bindings to the DataBindings collection.
    NewTree.DataBindings.Add(RootBinding);
    NewTree.DataBindings.Add(ParentBinding); 
    NewTree.DataBindings.Add(LeafBinding);

    // Manually register the event handler for the SelectedNodeChanged event.
    NewTree.SelectedNodeChanged += new EventHandler(this.Node_Change);

    // Add the TreeView control to the Controls collection of the PlaceHolder control.
    ControlPlaceHolder.Controls.Add(NewTree);

  }

  void Node_Change(Object sender, EventArgs e)
  {

    // Retrieve the TreeView control from the Controls collection of the PlaceHolder control.
    TreeView LocalTree = (TreeView)ControlPlaceHolder.FindControl("BookTreeView");

    // Display the selected node.
    Message.Text = "You selected: " + LocalTree.SelectedNode.Text;

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeView Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView Constructor Example</h3>
      
      <asp:PlaceHolder id="ControlPlaceHolder" runat="server">
      </asp:PlaceHolder>
   
      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Book.xml"
        runat="server">
      </asp:XmlDataSource>
      
      <br /><br />
      
      <asp:Label id="Message" runat="server"/>
    
    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

    ' Create a new TreeView control.
    Dim NewTree As New TreeView

    ' Set the properties of the TreeView control.
    NewTree.ID = "BookTreeView"
    NewTree.DataSourceID = "BookXmlDataSource"

    ' Create the tree node binding relationship.

    ' Create the root node binding.
    Dim RootBinding As New TreeNodeBinding
    RootBinding.DataMember = "Book"
    RootBinding.TextField = "Title"

    ' Create the parent node binding.
    Dim ParentBinding As New TreeNodeBinding
    ParentBinding.DataMember = "Chapter"
    ParentBinding.TextField = "Heading"

    ' Create the leaf node binding.
    Dim LeafBinding As New TreeNodeBinding
    LeafBinding.DataMember = "Section"
    LeafBinding.TextField = "Heading"

    ' Add bindings to the DataBindings collection.
    NewTree.DataBindings.Add(RootBinding)
    NewTree.DataBindings.Add(ParentBinding)
    NewTree.DataBindings.Add(LeafBinding)

    ' Manually register the event handler for the SelectedNodeChanged event.
    AddHandler NewTree.SelectedNodeChanged, AddressOf Node_Change

    ' Add the TreeView control to the Controls collection of the PlaceHolder control.
    ControlPlaceHolder.Controls.Add(NewTree)

  End Sub

  Sub Node_Change(ByVal sender As Object, ByVal e As EventArgs)

    ' Retrieve the TreeView control from the Controls collection of the PlaceHolder control.
    Dim LocalTree As TreeView = CType(ControlPlaceHolder.FindControl("BookTreeView"), TreeView)

    ' Display the selected node.
    Message.Text = "You selected: " & LocalTree.SelectedNode.Text

  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeView Constructor Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView Constructor Example</h3>
      
      <asp:PlaceHolder id="ControlPlaceHolder" runat="server">
      </asp:PlaceHolder>
   
      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Book.xml"
        runat="server">
      </asp:XmlDataSource>
      
      <br /><br />
      
      <asp:Label id="Message" runat="server"/>
    
    </form>
  </body>
</html>

다음은 앞의 코드 예제에 대 한 XML 데이터입니다.

<Book Title="Book Title">  
    <Chapter Heading="Chapter 1">  
       <Section Heading="Section 1">  
       </Section>  
       <Section Heading="Section 2">  
       </Section>  
    </Chapter>  
    <Chapter Heading="Chapter 2">  
        <Section Heading="Section 1">  
        </Section>  
    </Chapter>  
</Book>  

설명

합니다 TreeNodeBindingCollection 클래스 저장 하 고 컬렉션을 관리 하는 데 사용 됩니다 TreeNodeBinding 개체는 TreeView 제어 합니다. 합니다 TreeView 컨트롤이 사용 하는 TreeNodeBindingCollection 클래스에 대 한 해당 DataBindings 속성입니다.

합니다 DataBindings 속성에 들어 TreeNodeBinding 데이터 항목과 데이터 항목이 바인딩되는 노드 간의 관계를 정의 하는 개체입니다. 노드를 각 데이터 항목 (예: 몇 가지 특성을 사용 하 여 XML 요소), 여러 속성이 들어 있는 데이터 원본에 바인딩에서 반환 되는 값을 표시 하는 경우는 ToString 메서드 기본적으로 데이터 항목의 합니다. XML 요소가 아닌 경우 노드 트리의 기본 구조를 보여주지만 그렇지 않은 경우에 그다지 유용 하지는 요소 이름을 표시 합니다. 트리 노드 바인딩을 지정 하 여 노드는 특정 데이터 항목 속성에 바인딩할 수 있습니다. 하지만 DataBindings 선언적으로 설정할 일반적으로, 컬렉션을 프로그래밍 방식으로 채울 수 있습니다.

트리 노드 바인딩을 설정 하려면 선언적으로:

  1. 열기 및 닫기 중첩 <DataBindings> 을 열고 닫는 태그 사이 TreeView 제어 합니다.

  2. 장소 <asp:TreeNodeBinding> 요소는 태그와 닫는 사이 <DataBindings> 지정 하려는 각 트리 노드 바인딩에 대 한 태그입니다.

프로그래밍 방식으로 관리할 수 있습니다는 TreeNodeBindingCollection 추가 및 제거 하 여 TreeNodeBinding 개체입니다. 추가 하는 TreeNodeBinding 개체를 사용 하 여 컬렉션에는 Add 또는 Insert 메서드. 컬렉션에서 노드를 제거 하려면 사용 합니다 Remove, RemoveAt, 또는 StateManagedCollection.Clear 메서드.

TreeNodeBindingCollection 클래스는 컬렉션의 항목에 액세스 하는 여러 방법을 지원 합니다.

속성

Count

StateManagedCollection 컬렉션에 포함된 요소의 개수를 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
Item[Int32]

TreeNodeBinding 개체의 지정된 인덱스에 있는 TreeNodeBindingCollection 개체를 가져오거나 설정합니다.

메서드

Add(TreeNodeBinding)

지정된 TreeNodeBinding 개체를 TreeNodeBindingCollection 개체의 끝에 추가합니다.

Clear()

StateManagedCollection 컬렉션에서 모든 항목을 제거합니다.

(다음에서 상속됨 StateManagedCollection)
Contains(TreeNodeBinding)

지정된 TreeNodeBinding 개체가 컬렉션에 있는지 여부를 확인합니다.

CopyTo(Array, Int32)

특정 배열 인덱스부터 StateManagedCollection 컬렉션의 요소를 배열에 복사합니다.

(다음에서 상속됨 StateManagedCollection)
CopyTo(TreeNodeBinding[], Int32)

대상 배열의 지정한 인덱스부터 시작하여 TreeNodeBindingCollection 개체의 모든 항목을 TreeNodeBinding 개체의 호환되는 1차원 배열에 복사합니다.

CreateKnownType(Int32)

파생 클래스에서 재정의된 경우 IStateManager를 구현하는 클래스의 인스턴스를 만듭니다. 만들어진 개체의 형식은 GetKnownTypes() 메서드에서 반환된 컬렉션의 지정된 멤버를 기반으로 합니다.

(다음에서 상속됨 StateManagedCollection)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetEnumerator()

StateManagedCollection 컬렉션을 반복하는 반복기를 반환합니다.

(다음에서 상속됨 StateManagedCollection)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetKnownTypes()

파생 클래스에서 재정의된 경우 StateManagedCollection 컬렉션에 포함할 수 있는 IStateManager 형식의 배열을 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IndexOf(TreeNodeBinding)

컬렉션에서 지정된 TreeNodeBinding 개체의 인덱스를 확인합니다.

Insert(Int32, TreeNodeBinding)

지정된 TreeNodeBinding 개체를 TreeNodeBindingCollection 개체의 지정된 인덱스 위치에 삽입합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
OnClear()

파생 클래스에서 재정의된 경우 Clear() 메서드가 컬렉션에서 항목을 모두 제거하기 전에 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnClearComplete()

파생 클래스에서 재정의된 경우 Clear() 메서드가 컬렉션에서 항목을 모두 제거한 후 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnInsert(Int32, Object)

파생 클래스에서 재정의된 경우 IList.Insert(Int32, Object) 또는 IList.Add(Object) 메서드가 컬렉션에 항목을 추가하기 전에 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnInsertComplete(Int32, Object)

파생 클래스에서 재정의된 경우 IList.Insert(Int32, Object) 또는 IList.Add(Object) 메서드가 컬렉션에 항목을 추가한 후 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnRemove(Int32, Object)

파생 클래스에서 재정의된 경우 IList.Remove(Object) 또는 IList.RemoveAt(Int32) 메서드가 컬렉션에서 지정한 항목을 제거하기 전에 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnRemoveComplete(Int32, Object)

파생 클래스에서 재정의된 경우 IList.Remove(Object) 또는 IList.RemoveAt(Int32) 메서드가 컬렉션에서 지정한 항목을 제거한 후에 추가 작업을 수행합니다.

(다음에서 상속됨 StateManagedCollection)
OnValidate(Object)

파생 클래스에서 재정의된 경우 StateManagedCollection 컬렉션 요소의 유효성을 검사합니다.

(다음에서 상속됨 StateManagedCollection)
Remove(TreeNodeBinding)

TreeNodeBinding 개체에서 지정한 TreeNodeBindingCollection 개체를 제거합니다.

RemoveAt(Int32)

TreeNodeBinding 개체에서 지정한 인덱스에 있는 TreeNodeBindingCollection 개체를 제거합니다.

SetDirty()

전체 StateManagedCollection 컬렉션이 뷰 상태에 직렬화되도록 합니다.

(다음에서 상속됨 StateManagedCollection)
SetDirtyObject(Object)

파생 클래스에서 재정의된 경우 변경 정보만 기록하는 대신 전체 상태를 뷰 상태에 기록하도록 컬렉션에 포함된 object에 지시합니다.

(다음에서 상속됨 StateManagedCollection)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

ICollection.Count

StateManagedCollection 컬렉션에 포함된 요소의 개수를 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
ICollection.IsSynchronized

StateManagedCollection 컬렉션이 동기화되어 스레드로부터 안전하게 보호되는지 여부를 나타내는 값을 가져옵니다. 이 메서드는 항상 false를 반환합니다.

(다음에서 상속됨 StateManagedCollection)
ICollection.SyncRoot

StateManagedCollection 컬렉션에 대한 액세스를 동기화하는 데 사용할 수 있는 개체를 가져옵니다. 이 메서드는 항상 null를 반환합니다.

(다음에서 상속됨 StateManagedCollection)
IEnumerable.GetEnumerator()

StateManagedCollection 컬렉션을 반복하는 반복기를 반환합니다.

(다음에서 상속됨 StateManagedCollection)
IList.Add(Object)

StateManagedCollection 컬렉션에 항목을 추가합니다.

(다음에서 상속됨 StateManagedCollection)
IList.Clear()

StateManagedCollection 컬렉션에서 모든 항목을 제거합니다.

(다음에서 상속됨 StateManagedCollection)
IList.Contains(Object)

StateManagedCollection 컬렉션에 특정 값이 있는지 여부를 확인합니다.

(다음에서 상속됨 StateManagedCollection)
IList.IndexOf(Object)

StateManagedCollection 컬렉션에서 지정한 항목의 인덱스를 확인합니다.

(다음에서 상속됨 StateManagedCollection)
IList.Insert(Int32, Object)

항목을 StateManagedCollection 컬렉션 내의 지정한 인덱스에 삽입합니다.

(다음에서 상속됨 StateManagedCollection)
IList.IsFixedSize

StateManagedCollection 컬렉션의 크기가 고정되어 있는지 여부를 나타내는 값을 가져옵니다. 이 메서드는 항상 false를 반환합니다.

(다음에서 상속됨 StateManagedCollection)
IList.IsReadOnly

StateManagedCollection 컬렉션이 읽기 전용인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
IList.Item[Int32]

지정된 인덱스에 있는 IStateManager 요소를 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
IList.Remove(Object)

StateManagedCollection 컬렉션에서 맨 처음 발견되는 지정된 개체를 제거합니다.

(다음에서 상속됨 StateManagedCollection)
IList.RemoveAt(Int32)

지정한 인덱스에 있는 IStateManager 요소를 제거합니다.

(다음에서 상속됨 StateManagedCollection)
IStateManager.IsTrackingViewState

StateManagedCollection 컬렉션에서 해당 뷰 상태의 변경 내용을 저장하는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 StateManagedCollection)
IStateManager.LoadViewState(Object)

이전에 저장된 StateManagedCollection 컬렉션과 이 컬렉션에 포함된 IStateManager 항목의 뷰 상태를 복원합니다.

(다음에서 상속됨 StateManagedCollection)
IStateManager.SaveViewState()

페이지가 서버에 포스트백된 이후에 발생한 StateManagedCollection 컬렉션과 이 컬렉션에 포함된 각 IStateManager 개체의 변경 내용을 저장합니다.

(다음에서 상속됨 StateManagedCollection)
IStateManager.TrackViewState()

StateManagedCollection 컬렉션과 이 컬렉션에 포함된 각 IStateManager 개체가 해당 뷰 상태의 변경 내용을 추적하여 같은 페이지에서 발생하는 여러 요청에 대해 유지할 수 있도록 합니다.

(다음에서 상속됨 StateManagedCollection)

확장 메서드

Cast<TResult>(IEnumerable)

IEnumerable의 요소를 지정된 형식으로 캐스팅합니다.

OfType<TResult>(IEnumerable)

지정된 형식에 따라 IEnumerable의 요소를 필터링합니다.

AsParallel(IEnumerable)

쿼리를 병렬화할 수 있도록 합니다.

AsQueryable(IEnumerable)

IEnumerableIQueryable로 변환합니다.

적용 대상

추가 정보