Bagikan melalui


XmlDataSource.Data Properti

Definisi

Mendapatkan atau mengatur blok data XML yang diikat kontrol sumber data.

public:
 virtual property System::String ^ Data { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.TypeConverter("System.ComponentModel.MultilineStringConverter,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public virtual string Data { get; set; }
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.ComponentModel.TypeConverter("System.ComponentModel.MultilineStringConverter,System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public virtual string Data { get; set; }
[<System.ComponentModel.TypeConverter("System.ComponentModel.MultilineStringConverter,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")>]
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.Data : string with get, set
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
[<System.ComponentModel.TypeConverter("System.ComponentModel.MultilineStringConverter,System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")>]
member this.Data : string with get, set
Public Overridable Property Data As String

Nilai Properti

String data XML sebaris yang diikat XmlDataSource kontrol. Nilai defaultnya adalah Empty.

Atribut

Pengecualian

Dokumen sedang dimuat.

Contoh

Contoh kode berikut menunjukkan cara menggunakan XmlDataSource kontrol untuk menampilkan data XML sebaris yang dimuat oleh Data properti dengan TreeView kontrol.

<%@ 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" >
        <data>
          <Books>
            <LanguageBooks>
              <Book Title="Pure JavaScript" Author="Wyke, Gilliam, and Ting"/>
              <Book Title="Effective C++ Second Edition" Author="Scott Meyers"/>
              <Book Title="Assembly Language Step-By-Step" Author="Jeff Duntemann"/>
              <Book Title="Oracle PL/SQL" Author="Steven Feuerstein"/>
            </LanguageBooks>
            <SecurityBooks>
              <Book Title="Counter Hack" Author="Ed Skoudis"/>
            </SecurityBooks>
          </Books>
        </data>
        </asp:xmldatasource>

      <!- 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" >
        <data>
          <Books>
            <LanguageBooks>
              <Book Title="Pure JavaScript" Author="Wyke, Gilliam, and Ting"/>
              <Book Title="Effective C++ Second Edition" Author="Scott Meyers"/>
              <Book Title="Assembly Language Step-By-Step" Author="Jeff Duntemann"/>
              <Book Title="Oracle PL/SQL" Author="Steven Feuerstein"/>
            </LanguageBooks>
            <SecurityBooks>
              <Book Title="Counter Hack" Author="Ed Skoudis"/>
            </SecurityBooks>
          </Books>
        </data>
        </asp:xmldatasource>

      <!- 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>

Keterangan

Dalam skenario deklaratif, Data properti ditentukan sebagai properti dalam multibaris objek XmlDataSource . Properti dalam kompatibel dengan data XML, karena memungkinkan Anda memformat data XML dengan cara apa pun dan mengabaikan masalah padding karakter, seperti karakter kutipan padding.

DataFile Jika properti dan Data diatur, DataFile properti diutamakan dan data dalam file XML digunakan alih-alih data XML yang ditentukan dalam Data properti .

Jika Anda mengubah nilai Data properti , DataSourceChanged peristiwa akan dinaikkan. Jika penembolokan diaktifkan dan Anda mengubah nilai Data, cache tidak valid.

Berlaku untuk

Lihat juga