XmlDataSource.DataFile 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
데이터 소스가 바인딩된 XML 파일의 파일 이름을 지정합니다.
public:
virtual property System::String ^ DataFile { System::String ^ get(); void set(System::String ^ value); };
public virtual string DataFile { get; set; }
member this.DataFile : string with get, set
Public Overridable Property DataFile As String
속성 값
XmlDataSource 컨트롤이 나타내는 데이터를 포함하는 XML 파일의 절대 실제 경로 또는 상대 경로입니다. 기본값은 Empty입니다.
예외
문서를 로드하고 있는 경우
예제
다음 코드 예제에 사용 하는 방법을 보여 줍니다.는 XmlDataSource 인 파일에 포함 된 XML 데이터를 표시 하도록 컨트롤을 TreeView 제어 합니다.
<%@ 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" />
<!- 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" />
<!- 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>
설명
모두를 DataFile 및 Data 속성을 설정 합니다 DataFile 속성이 우선 하 고 XML 파일의 데이터에 지정 된 XML 데이터 대신 사용 됩니다는 Data 속성입니다.
값을 변경 하는 경우는 DataFile 속성을 DataSourceChanged 이벤트가 발생 합니다. 캐싱을 사용 하는 및의 값을 변경 하는 경우 DataFile, 캐시를 무효화 합니다.