XmlDataSource.EnableCaching 속성

정의

XmlDataSource 컨트롤에서 데이터 캐싱이 활성화되어 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

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

속성 값

Boolean

데이터 소스 컨트롤에서 데이터 캐싱을 사용할 수 있으면 true이고, 그렇지 않으면 false입니다. 기본값은 true입니다.

예제

다음 코드 예제에서는 사용 하는 경우 캐싱을 사용 하도록 설정 하는 방법에 설명 합니다 XmlDataSource XML 파일에 포함 된 데이터를 표시 하는 컨트롤입니다. 캐싱을 사용 하는 경우는 EnableCaching 속성이로 설정 되어 trueCacheDuration 데이터 소스 컨트롤에서 데이터 캐시 되는 시간 (초) 수로 설정 됩니다.

<%@ 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>ASP.NET Example</title>
</head>
<body>

    <form id="form1" runat="server">
      <asp:xmldatasource
        id="XmlDataSource1"
        runat="server"
        datafile="books.xml"
        enablecaching="True"
        cacheduration="60"
        cacheexpirationpolicy="Sliding" />

      <!- TreeView uses hierachical data, so the
          XmlDataSource uses an XmlHierarchicalDataSourceView
          when a TreeView is bound to it. -->

      <asp:treeview
        id="TreeView1"
        runat="server"
        datasourceid="XmlDataSource1">
        <databindings>
          <asp:treenodebinding datamember="book" textfield="title"/>
        </databindings>
      </asp:treeview>

    </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>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <asp:xmldatasource
        id="XmlDataSource1"
        runat="server"
        datafile="books.xml"
        enablecaching="True"
        cacheduration="60"
        cacheexpirationPolicy="Sliding" />

      <!- TreeView uses hierachical data, so the
          XmlDataSource uses an XmlHierarchicalDataSourceView
          when a TreeView is bound to it. -->

      <asp:treeview
        id="TreeView1"
        runat="server"
        datasourceid="XmlDataSource1">
        <databindings>
          <asp:treenodebinding datamember="book" textfield="title"/>
        </databindings>
      </asp:treeview>

    </form>
  </body>
</html>

코드 예제에서 XML 파일에 다음 데이터가 있습니다.

<books>  
   <computerbooks>  
     <book title="Secrets of Silicon Valley" author="Sheryl Hunter"/>  
     <book title="Straight Talk About Computers" author="Dean Straight"/>  
     <book title="You Can Combat Computer Stress!" author="Marjorie Green"/>                  
   </computerbooks>  
   <cookbooks>  
     <book title="Silicon Valley Gastronomic Treats" author="Innes del Castill"/>  
   </cookbooks>  
</books>  

설명

XmlDataSource 컨트롤은 자동으로 데이터를 캐시 때 합니다 EnableCaching 속성이 true합니다. 기본적으로 CacheDuration 속성 무한 캐시를 나타내는 0으로 설정 되 고 종속 되는 XML 파일이 변경 될 때까지 데이터 원본의 데이터를 캐시 합니다. 설정 하는 경우는 CacheDuration 0 보다 큰 값으로 속성 캐시는 새로운 집합을 검색 하는 많은 초에 대 한 데이터를 저장 합니다.

경우는 EnableCaching 속성이 true 하며 TransformArgumentList 속성을 설정 하면 변환 인수 목록에 있는 매개 변수를 변경 하는 경우 캐시 항목을 자동으로 무효화 되지 않습니다. 설정 하 여 캐시를 무효화 하는 코드를 작성 해야 하는 경우는 CacheKeyDependency 속성입니다.

적용 대상

추가 정보