TreeNodeBinding.PopulateOnDemand 속성

정의

TreeNodeBinding 개체가 적용된 노드를 동적으로 채울 것인지 여부를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool PopulateOnDemand { bool get(); void set(bool value); };
public bool PopulateOnDemand { get; set; }
member this.PopulateOnDemand : bool with get, set
Public Property PopulateOnDemand As Boolean

속성 값

TreeNodeBinding 개체가 적용된 노드를 동적으로 채우려면 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

예제

이 섹션에는 두 코드 예제가 있습니다. 첫 번째 코드 예제를 사용 하는 방법에 설명 합니다 ShowCheckBox 노드에 대 한 확인란을 표시 하는지 여부를 지정 하는 속성입니다. 두 번째 코드 예제에서는 첫 번째 코드 예제에 대 한 샘플 XML 데이터를 제공합니다.

다음 예제에서는 사용 하는 방법에 설명 합니다 ShowCheckBox 노드에 대 한 확인란을 표시 하는지 여부를 지정 하는 속성입니다. 이 예제가 제대로 작동 하려면에 대 한 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 TreeNodeBinding object and set its 
    // properties.
    TreeNodeBinding binding = new TreeNodeBinding();
    binding.DataMember = "Section";
    binding.Depth = 2;
    binding.TextField = "Heading";

    // Set the PopulateOnDemand property of the
    // TreeNodeBinding object programmatically.
    binding.PopulateOnDemand = false;

    // Add the TreeNodeBinding object to the DataBindings
    // collection of the TreeView control.
    BookTreeView.DataBindings.Add(binding);

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNodeBinding PopulateOnDemand Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNodeBinding PopulateOnDemand Example</h3>
    
      <asp:TreeView id="BookTreeView" 
        DataSourceID="BookXmlDataSource"
        ExpandDepth="2"  
        runat="server">
         
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Book" 
            TextField="Title"/>
          <asp:TreeNodeBinding DataMember="Chapter" 
            TextField="Heading"
            PopulateOnDemand="False"/>
          <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">
<script runat="server">

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

    ' Create a TreeNodeBinding object and set its 
    ' properties.
    Dim binding As TreeNodeBinding = New TreeNodeBinding
    binding.DataMember = "Section"
    binding.Depth = 2
    binding.TextField = "Heading"

    ' Set the PopulateOnDemand property of the
    ' TreeNodeBinding object programmatically.
    binding.PopulateOnDemand = False

    ' Add the TreeNodeBinding object to the DataBindings
    ' collection of the TreeView control.
    BookTreeView.DataBindings.Add(binding)

  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeNodeBinding PopulateOnDemand Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeNodeBinding PopulateOnDemand Example</h3>
    
      <asp:TreeView id="BookTreeView" 
        DataSourceID="BookXmlDataSource"
        ExpandDepth="2"  
        runat="server">
         
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Book" 
            TextField="Title"/>
          <asp:TreeNodeBinding DataMember="Chapter" 
            TextField="Heading"
            PopulateOnDemand="False"/>
          <asp:TreeNodeBinding DataMember="Section" 
            TextField="Heading"/>
        </DataBindings>
         
      </asp:TreeView>
      
      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Book.xml"
        runat="server">
      </asp:XmlDataSource>
    
    </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>  
    <Appendix Heading="Appendix A">  
    </Appendix>  
</Book>  

설명

경우에 따라 정적으로 인해 데이터 크기 또는 사용자 입력에 따라 달라 지는 사용자 지정 콘텐츠 트리 구조는 미리 정의 실용적이 지 않습니다. 이 인해는 TreeView 컨트롤은 동적 노드 채우기를 지원 합니다. 경우는 PopulateOnDemand 속성이 true, 노드의 자식 노드는는 TreeNodeBinding 개체 가져옵니다에 적용 됩니다 노드를 확장 하는 경우 런타임 시 채워집니다.

데이터 바인딩을 설정 하 여 만든 경우는 AutoGenerateDataBindingsTreeView 컨트롤을 true, 생성 된 바인딩의 합니다 PopulateOnDemand 속성이로 설정 true합니다. 데이터 바인딩에 선언적으로 만들어진 합니다 PopulateOnDemand 속성이 설정 false합니다. 선언적 구문을 사용 하 여 개별 데이터 바인딩의 동작을 제어할 수 있습니다.

참고

달리를 PopulateOnDemand 의 속성을 TreeNode 클래스는 PopulateOnDemand 속성에 대해 정의 하는 이벤트 처리 메서드를 필요가 없습니다를 TreeNodePopulate 이벤트와 같은 데이터 소스 컨트롤을 사용 하는 경우 XmlDataSource. 대신 합니다 TreeView 컨트롤의 속성을 사용 하는 이벤트 처리 메서드를 동적으로 생성 합니다 TreeNodeBinding 개체는 DataBindings 컬렉션입니다. 에 대 한 이벤트 처리 메서드를 계속 정의할 수 있습니다는 TreeNodePopulate 이벤트가 있습니다; 그러나 이벤트 처리 메서드를 이후에 호출 됩니다는 TreeView 컨트롤입니다.

지원 되는 브라우저 클라이언트 쪽 노드의 채우기를 사용할 수도 있습니다. 이 기능을 사용 합니다 TreeView 해당 노드가 확장 되는 서버에 다시 게시할 필요가 없는 경우 클라이언트에서 동적으로 노드를 채울 컨트롤입니다. 클라이언트 쪽 노드의 인구에 대 한 자세한 내용은 참조 하세요. PopulateNodesFromClient합니다.

이 속성의 값은 뷰 상태에 저장 됩니다.

적용 대상

추가 정보