Bagikan melalui


TreeNodeBinding.NavigateUrlField Properti

Definisi

Mendapatkan atau mengatur nama bidang dari sumber data untuk mengikat properti NavigateUrlTreeNode objek tempat TreeNodeBinding objek diterapkan.

public:
 property System::String ^ NavigateUrlField { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string NavigateUrlField { get; set; }
[System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
public string NavigateUrlField { get; set; }
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.NavigateUrlField : string with get, set
[<System.ComponentModel.TypeConverter("System.Web.UI.Design.DataSourceViewSchemaConverter, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]
member this.NavigateUrlField : string with get, set
Public Property NavigateUrlField As String

Nilai Properti

Nama bidang yang akan diikat ke NavigateUrl properti TreeNode objek tempat TreeNodeBinding objek diterapkan. Defaultnya adalah string kosong (""), yang menunjukkan bahwa NavigateUrlField properti tidak diatur.

Atribut

Contoh

Bagian ini berisi dua contoh kode. Contoh kode pertama menunjukkan cara menggunakan NavigateUrlField properti untuk menentukan atribut elemen XML mana yang akan diikat ke NavigateUrl properti TreeNode objek tempat TreeNodeBinding objek diterapkan. Contoh kode kedua menyediakan contoh data XML untuk contoh kode pertama.

Contoh kode berikut menunjukkan cara menggunakan NavigateUrlField properti untuk menentukan atribut elemen XML mana yang akan diikat ke NavigateUrl properti TreeNode objek tempat TreeNodeBinding objek diterapkan. Agar contoh ini berfungsi dengan benar, Anda harus menyalin data XML sampel, yang disediakan setelah contoh kode ini, ke file bernama Booklist.xml.


<%@ 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>TreeViewBinding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeViewBinding Example</h3>
    
      <!-- Set the TextField, ImageUrlField, NavigateUrlField, -->
      <!-- ValueField, and ToolTipField properties of a    -->
      <!-- TreeNodeBinding object declaratively.         -->
      <asp:TreeView id="BookTreeView" 
        DataSourceID="BookXmlDataSource"
        Target="_blank" 
        runat="server">
          
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Books" 
            Depth="0" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Book" 
            Depth="1" 
            TextField="Text" 
            ImageUrlField="Image"
            ImageToolTipField="ImageToolTip" 
            NavigateUrlField="Nav" 
            ValueField="Value" 
            ToolTipField="Tip"/>
          <asp:TreeNodeBinding DataMember="Description" 
            Depth="2" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Price" 
            Depth="2" 
            TextField="Value"/>
        </DataBindings>
         
      </asp:TreeView>
      
      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Booklist.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">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeViewBinding Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeViewBinding Example</h3>
    
      <!-- Set the TextField, ImageUrlField, NavigateUrlField, -->
      <!-- ValueField, and ToolTipField properties of a    -->
      <!-- TreeNodeBinding object declaratively.         -->
      <asp:TreeView id="BookTreeView" 
        DataSourceID="BookXmlDataSource"
        Target="_blank" 
        runat="server">
          
        <DataBindings>
          <asp:TreeNodeBinding DataMember="Books" 
            Depth="0" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Book" 
            Depth="1" 
            TextField="Text" 
            ImageUrlField="Image"
            ImageToolTipField="ImageToolTip" 
            NavigateUrlField="Nav" 
            ValueField="Value" 
            ToolTipField="Tip"/>
          <asp:TreeNodeBinding DataMember="Description" 
            Depth="2" 
            TextField="Text"/>
          <asp:TreeNodeBinding DataMember="Price" 
            Depth="2" 
            TextField="Value"/>
        </DataBindings>
         
      </asp:TreeView>
      
      <asp:XmlDataSource id="BookXmlDataSource"  
        DataFile="Booklist.xml"
        runat="server">
      </asp:XmlDataSource>
    
    </form>
  </body>
</html>

Contoh kode berikut menyediakan contoh data XML untuk contoh kode sebelumnya.

<Books Text="Books List">
    <Book Text="Book Title One"
        Value="1"
        Image="Bookimage1.jpg"
        ImageToolTip="Book 1 Photo"
        Nav="http://www.microsoft.com"
        Tip="Book Title 1">
        <Description Text="Book Description">
        </Description>
        <Price Value="$1.99">
        </Price>
        <Author Text="Author Name"
            Value="LastName"
            Image="Authorimage1.jpg"
            Nav="http://www.microsoft.com"
            Tip="Author Name">
        </Author>
    </Book>
    <Book Text="Book Title Two"
        Value="2"
        Image="Bookimage2.jpg"
        ImageToolTip="Book 2 Photo"
        Nav="http://www.microsoft.com"
        Tip="Click Me">
        <Description Text="Book Description">
        </Description>
        <Price Value="$2.99">
        </Price>
        <Author Text="Author Name"
            Value="LastName"
            Image="Authorimage2.jpg"
            Nav="http://www.microsoft.com"
            Tip="Author Name">
        </Author>
    </Book>
</Books>

Keterangan

TreeView Saat kontrol terikat ke sumber data, gunakan NavigateUrlField properti untuk menentukan nama bidang yang akan diikat ke NavigateUrl properti TreeNode objek. Hubungan pengikatan ini memengaruhi semua TreeNode objek tempat TreeNodeBinding objek diterapkan. NavigateUrlField Saat properti diatur, TreeView kontrol menampilkan hyperlink untuk teks simpul, bukan teks biasa. Anda juga dapat secara opsional mengatur Target properti untuk menentukan jendela atau bingkai untuk menampilkan konten yang ditautkan.

Nota

Anda dapat secara selektif mengambil alih NavigateUrlField properti dengan mengatur NavigateUrl properti setiap simpul secara langsung.

Alih-alih menggunakan NavigateUrlField properti untuk mengikat NavigateUrl properti TreeNode objek ke bidang, Anda dapat mengatur NavigateUrl properti ke nilai tetap dengan mengatur NavigateUrl properti .

Nota

Jika sumber data berisi beberapa bidang, Anda harus terlebih dahulu mengatur Depth properti atau DataMember , atau kedua properti untuk mengikat ke bidang yang sesuai.

Nilai properti ini disimpan dalam status tampilan.

Berlaku untuk

Lihat juga