XmlDataSource.Data XmlDataSource.Data XmlDataSource.Data XmlDataSource.Data Property

Definizione

Ottiene o imposta un blocco di dati XML a cui si associa il controllo origine dati.Gets or sets a block of XML data that the data source control binds to.

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

Valore della proprietà

Stringa di dati XML inline a cui si associa il controllo XmlDataSource.A string of inline XML data that the XmlDataSource control binds to. Il valore predefinito è Empty.The default value is Empty.

Eccezioni

È in corso il caricamento del documento.The document is loading.

Esempi

Esempio di codice seguente viene illustrato come utilizzare un XmlDataSource controllo per visualizzare i dati XML contenuti il Data proprietà con un TreeView controllo.The following code example demonstrates how to use an XmlDataSource control to display inline XML data contained by the Data property with a TreeView control.

<%@ 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>

Commenti

Negli scenari dichiarativi, la Data proprietà viene specificata come una proprietà interna su più righe del XmlDataSource oggetto.In declarative scenarios, the Data property is specified as a multiline inner property of the XmlDataSource object. Una proprietà interna è compatibile con i dati XML, perché ti consente di formattare i dati XML in alcun modo e ignorare i problemi di riempimento caratteri, ad esempio le virgolette di riempimento.An inner property is compatible with XML data, because it enables you to format the XML data in any way and ignore character padding issues, such as padding quote characters.

Se entrambi i DataFile e Data sono impostate, il DataFile proprietà ha la precedenza e i dati nel file XML viene usati invece i dati XML specificati nel Data proprietà.If both the DataFile and Data properties are set, the DataFile property takes precedence and the data in the XML file is used instead of the XML data specified in the Data property.

Se si modifica il valore della Data proprietà, il DataSourceChanged viene generato l'evento.If you change the value of the Data property, the DataSourceChanged event is raised. Se la memorizzazione nella cache è abilitata e si modifica il valore di Data, la cache viene invalidata.If caching is enabled and you change the value of Data, the cache is invalidated.

Si applica a

Vedi anche