IBindableTemplate IBindableTemplate IBindableTemplate IBindableTemplate Interface

定義

提供一種方法給 DetailsView 以及 FormView 之類的 ASP.NET 資料繫結控制項,讓它們能夠自動繫結到樣板化內容區段內的 ASP.NET 資料來源控制項。Provides a way for ASP.NET data-bound controls, such as DetailsView and FormView, to automatically bind to an ASP.NET data source control within templated content sections.

public interface class IBindableTemplate : System::Web::UI::ITemplate
public interface IBindableTemplate : System.Web.UI.ITemplate
type IBindableTemplate = interface
    interface ITemplate
Public Interface IBindableTemplate
Implements ITemplate
衍生
實作

範例

下列程式碼範例會示範FormView控制項如何以宣告方式定義樣板化內容、系結至SqlDataSource控制項所提供的資料, 以及顯示和編輯現有的記錄。The following code example demonstrates how a FormView control can declaratively define templated content, bind to data provided by a SqlDataSource control, and display and edit existing records. ASP.NET 剖析器會剖析樣板化的內容, IBindableTemplate並在執行時間建立物件, 以便能夠SqlDataSource從控制項將值系結至範本中定義的資料系結區域, 這兩種方法都是單向 ASP.NET 資料系結語法 (<%# Eval("fieldname") %>) 和雙向資料系結語法 (<%# Bind("fieldname") %>)。The ASP.NET parser parses the templated content and creates an IBindableTemplate object at run time that is able to bind values from the SqlDataSource control to the data-binding areas defined in the template by both one-way ASP.NET data-binding syntax (<%# Eval("fieldname") %>) and two-way data-binding syntax (<%# Bind("fieldname") %>).

重要

此控制項有一個可接受使用者輸入的文字方塊, 這是潛在的安全性威脅。This control has a text box that accepts user input, which is a potential security threat. 根據預設,ASP.NET Web 網頁會驗證使用者輸入未包含指令碼或 HTML 項目。By default, ASP.NET Web pages validate that user input does not include script or HTML elements. 如需詳細資訊,請參閱 Script Exploits Overview (指令碼攻擊概觀)。For more information, see Script Exploits Overview.


<%@ Page language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void EmployeeFormView_ItemUpdating(Object sender, FormViewUpdateEventArgs e)
  {

    // Validate the field values entered by the user. This
    // example determines whether the user left any fields
    // empty. Use the NewValues property to access the new 
    // values entered by the user.
    ArrayList emptyFieldList = ValidateFields(e.NewValues);

    if (emptyFieldList.Count > 0)
    {

      // The user left some fields empty. Display an error message.
      
      // Use the Keys property to retrieve the key field value.
      String keyValue = e.Keys["EmployeeID"].ToString();

      MessageLabel.Text = "You must enter a value for each field of record " +
        keyValue + ".<br/>The following fields are missing:<br/><br/>";

      // Display the missing fields.
      foreach (String value in emptyFieldList)
      {
        // Use the OldValues property to access the original value
        // of a field.
        MessageLabel.Text += value + " - Original Value = " + 
          e.OldValues[value].ToString() + "<br />";
      }

      // Cancel the update operation.
      e.Cancel = true;

    }
    else
    {
      // The field values passed validation. Clear the
      // error message label.
      MessageLabel.Text = "";
    }

  }

  ArrayList ValidateFields(IOrderedDictionary list)
  {
    
    // Create an ArrayList object to store the
    // names of any empty fields.
    ArrayList emptyFieldList = new ArrayList();

    // Iterate though the field values entered by
    // the user and check for an empty field. Empty
    // fields contain a null value.
    foreach (DictionaryEntry entry in list)
    {
      if (entry.Value == String.Empty)
      {
        // Add the field name to the ArrayList object.
        emptyFieldList.Add(entry.Key.ToString());
      }
    }

    return emptyFieldList;
  }

  void EmployeeFormView_ModeChanging(Object sender, FormViewModeEventArgs e)
  {
    if (e.CancelingEdit)
    {
      // The user canceled the update operation.
      // Clear the error message label.
      MessageLabel.Text = "";
    }
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>FormView Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormView Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        headertext="Employee Record"
        emptydatatext="No employees found."
        onitemupdating="EmployeeFormView_ItemUpdating"
        onmodechanging="EmployeeFormView_ModeChanging"  
        runat="server">
        
        <headerstyle backcolor="CornFlowerBlue"
          forecolor="White"
          font-size="14"
          horizontalalign="Center"  
          wrap="false"/>
        <rowstyle backcolor="LightBlue"
          wrap="false"/>
        <pagerstyle backcolor="CornFlowerBlue"/>

        <itemtemplate>
          <table>
            <tr>
              <td rowspan="6">
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <%# Eval("FirstName") %> <%# Eval("LastName") %>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <%# Eval("Title") %>
              </td>
            </tr>
            <tr>
              <td>
                <b>Hire Date:</b>                 
              </td>
              <td>
                <%# Eval("HireDate","{0:d}") %>
              </td>
            </tr>
            <tr style="height:150; vertical-align:top">
              <td>
                <b>Address:</b>
              </td>
              <td>
                <%# Eval("Address") %><br/>
                <%# Eval("City") %> <%# Eval("Region") %>
                <%# Eval("PostalCode") %><br/>
                <%# Eval("Country") %>   
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="Edit"
                  text="Edit"
                  commandname="Edit"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </itemtemplate>
        <edititemtemplate>
          <table>
            <tr>
              <td rowspan="6">
                <asp:image id="EmployeeEditImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <asp:textbox id="FirstNameUpdateTextBox"
                  text='<%# Bind("FirstName") %>'
                  runat="server"/>
                <asp:textbox id="LastNameUpdateTextBox"
                  text='<%# Bind("LastName") %>'
                  runat="server"/>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <asp:textbox id="TitleUpdateTextBox"
                  text='<%# Bind("Title") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td>
                <b>Hire Date:</b>                 
              </td>
              <td>
                <asp:textbox id="HireDateUpdateTextBox"
                  text='<%# Bind("HireDate", "{0:d}") %>'
                  runat="server"/>
              </td>
            </tr>
            <tr style="height:150; vertical-align:top">
              <td>
                <b>Address:</b>
              </td>
              <td>
                <asp:textbox id="AddressUpdateTextBox"
                  text='<%# Bind("Address") %>'
                  runat="server"/>
                <br/>
                <asp:textbox id="CityUpdateTextBox"
                  text='<%# Bind("City") %>'
                  runat="server"/> 
                <asp:textbox id="RegionUpdateTextBox"
                  text='<%# Bind("Region") %>'
                  width="40"
                  runat="server"/>
                <asp:textbox id="PostalCodeUpdateTextBox"
                  text='<%# Bind("PostalCode") %>'
                  width="60"
                  runat="server"/>
                <br/>
                <asp:textbox id="CountryUpdateTextBox"
                  text='<%# Bind("Country") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="UpdateButton"
                  text="Update"
                  commandname="Update"
                  runat="server"/>
                <asp:linkbutton id="CancelButton"
                  text="Cancel"
                  commandname="Cancel"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </edititemtemplate>
          
        <pagersettings position="Bottom"
          mode="Numeric"/> 
                  
      </asp:formview>
      
      <br/><br/>
      
      <asp:label id="MessageLabel"
          forecolor="Red"
          runat="server"/>
          
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [Address], [City], [Region], [PostalCode], [Country], [HireDate], [PhotoPath] From [Employees]"
        updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName, [Title]=@Title, [Address]=@Address, [City]=@City, [Region]=@Region, [PostalCode]=@PostalCode, [Country]=@Country Where [EmployeeID]=@EmployeeID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </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">
<script runat="server">

  Sub EmployeeFormView_ItemUpdating(ByVal sender As Object, ByVal e As FormViewUpdateEventArgs) Handles EmployeeFormView.ItemUpdating
  
    ' Validate the field values entered by the user. This
    ' example determines whether the user left any fields
    ' empty. Use the NewValues property to access the new 
    ' values entered by the user.
        Dim emptyFieldList As ArrayList = ValidateFields(e.NewValues)

    If emptyFieldList.Count > 0 Then

      ' The user left some fields empty. Display an error message.
      
      ' Use the Keys property to retrieve the key field value.
      Dim keyValue As String = e.Keys("EmployeeID").ToString()

      MessageLabel.Text = "You must enter a value for each field of record " & _
        keyValue & ".<br/>The following fields are missing:<br/><br/>"

      ' Display the missing fields.
      Dim value As String
      For Each value In emptyFieldList
      
        ' Use the OldValues property to access the original value
        ' of a field.
        MessageLabel.Text &= value & " - Original Value = " & _
          e.OldValues(value).ToString() & "<br />"
        
      Next

      ' Cancel the update operation.
      e.Cancel = True

    Else
    
      ' The field values passed validation. Clear the
      ' error message label.
      MessageLabel.Text = ""
      
    End If

  End Sub

  Function ValidateFields(ByVal list As IOrderedDictionary) As ArrayList
    
    ' Create an ArrayList object to store the
    ' names of any empty fields.
    Dim emptyFieldList As New ArrayList()

    ' Iterate though the field values entered by
    ' the user and check for an empty field. Empty
    ' fields contain a null value.
    Dim entry As DictionaryEntry
    
    For Each entry In list
    
      If entry.Value Is String.Empty Then
      
        ' Add the field name to the ArrayList object.
        emptyFieldList.Add(entry.Key.ToString())
        
      End If
      
    Next

    Return emptyFieldList
  
  End Function
  
  Sub EmployeeFormView_ModeChanging(ByVal sender As Object, ByVal e As FormViewModeEventArgs) Handles EmployeeFormView.ModeChanging
  
    If e.CancelingEdit Then
      
      ' The user canceled the update operation.
      ' Clear the error message label.
      MessageLabel.Text = ""
    
    End If
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>FormView Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormView Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        headertext="Employee Record"
        emptydatatext="No employees found."
        runat="server">
        
        <headerstyle backcolor="CornFlowerBlue"
          forecolor="White"
          font-size="14"
          horizontalalign="Center"  
          wrap="false"/>
        <rowstyle backcolor="LightBlue"
          wrap="false"/>
        <pagerstyle backcolor="CornFlowerBlue"/>

        <itemtemplate>
          <table>
            <tr>
              <td rowspan="6">
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <%# Eval("FirstName") %> <%# Eval("LastName") %>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <%# Eval("Title") %>
              </td>
            </tr>
            <tr>
              <td>
                <b>Hire Date:</b>                 
              </td>
              <td>
                <%# Eval("HireDate","{0:d}") %>
              </td>
            </tr>
            <tr style="height:150; vertical-align:top">
              <td>
                <b>Address:</b>
              </td>
              <td>
                <%# Eval("Address") %><br/>
                <%# Eval("City") %> <%# Eval("Region") %>
                <%# Eval("PostalCode") %><br/>
                <%# Eval("Country") %>   
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="Edit"
                  text="Edit"
                  commandname="Edit"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </itemtemplate>
        <edititemtemplate>
          <table>
            <tr>
              <td rowspan="6">
                <asp:image id="EmployeeEditImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b>Name:</b>
              </td>
              <td>
                <asp:textbox id="FirstNameUpdateTextBox"
                  text='<%# Bind("FirstName") %>'
                  runat="server"/>
                <asp:textbox id="LastNameUpdateTextBox"
                  text='<%# Bind("LastName") %>'
                  runat="server"/>
              </td>
            </tr>
            <tr>
              <td>
                <b>Title:</b>
              </td>
              <td>
                <asp:textbox id="TitleUpdateTextBox"
                  text='<%# Bind("Title") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td>
                <b>Hire Date:</b>                 
              </td>
              <td>
                <asp:textbox id="HireDateUpdateTextBox"
                  text='<%# Bind("HireDate", "{0:d}") %>'
                  runat="server"/>
              </td>
            </tr>
            <tr style="height:150; vertical-align:top">
              <td>
                <b>Address:</b>
              </td>
              <td>
                <asp:textbox id="AddressUpdateTextBox"
                  text='<%# Bind("Address") %>'
                  runat="server"/>
                <br/>
                <asp:textbox id="CityUpdateTextBox"
                  text='<%# Bind("City") %>'
                  runat="server"/> 
                <asp:textbox id="RegionUpdateTextBox"
                  text='<%# Bind("Region") %>'
                  width="40"
                  runat="server"/>
                <asp:textbox id="PostalCodeUpdateTextBox"
                  text='<%# Bind("PostalCode") %>'
                  width="60"
                  runat="server"/>
                <br/>
                <asp:textbox id="CountryUpdateTextBox"
                  text='<%# Bind("Country") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="UpdateButton"
                  text="Update"
                  commandname="Update"
                  runat="server"/>
                <asp:linkbutton id="CancelButton"
                  text="Cancel"
                  commandname="Cancel"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </edititemtemplate>
          
        <pagersettings position="Bottom"
          mode="Numeric"/> 
                  
      </asp:formview>
      
      <br/><br/>
      
      <asp:label id="MessageLabel"
          forecolor="Red"
          runat="server"/>
          
      <!-- This example uses Microsoft SQL Server and connects  -->
      <!-- to the Northwind sample database. Use an ASP.NET     -->
      <!-- expression to retrieve the connection string value   -->
      <!-- from the Web.config file.                            -->
      <asp:sqldatasource id="EmployeeSource"
        selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [Address], [City], [Region], [PostalCode], [Country], [HireDate], [PhotoPath] From [Employees]"
        updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName, [Title]=@Title, [Address]=@Address, [City]=@City, [Region]=@Region, [PostalCode]=@PostalCode, [Country]=@Country Where [EmployeeID]=@EmployeeID"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </form>
  </body>
</html>

備註

FormView DetailsView SqlDataSource ObjectDataSource介面提供 ASP.NET 資料繫結控制項 (例如、 GridView和) 的方式, 以系結至 ASP.NET 資料來源控制項 (例如或) 所提供的資料 (當IBindableTemplate資料繫結控制項包含樣板化的內容。The IBindableTemplate interface provides a way for ASP.NET data-bound controls, such as DetailsView, GridView, and FormView, to bind to data supplied by an ASP.NET data source control, such as ObjectDataSource or SqlDataSource, when the data-bound control includes templated content.

注意

網頁開發人員不會IBindableTemplate執行介面。Page developers do not implement the IBindableTemplate interface. 建立自訂資料繫結控制項的開發人員IBindableTemplate可能會在PerformDataBindingExtractRowValues方法的實體系中操作物件, 但不IBindableTemplate會執行自己的物件。Developers creating custom data-bound controls might manipulate IBindableTemplate objects in implementations of the PerformDataBinding and ExtractRowValues methods, but do not implement their own IBindableTemplate objects.

資料繫結控制項 (例如GridView一般) 會感知其子控制項樹狀結構, 因此可以將值系結至它們、從它們提取值, 以及在資料系結髮生時, 于資料繫結控制項和資料來源控制項之間傳遞這些值。Data-bound controls such as GridView typically are aware of their child control trees, and can therefore bind values to them, extract values from them, and pass these values between the data-bound control and a data source control whenever data binding occurs. 不過, 當頁面開發人員定義資料繫結控制項的樣板化內容時, 父資料繫結控制項看不到範本中的子控制項: 父系可以呈現子內容 (因為控制項會有效呈現其本身)。但它無法將這些子控制項的值解壓縮, 以傳遞至相關聯的資料來源控制項的更新、插入或刪除作業。However, when a page developer defines templated content for a data-bound control, the child controls within the template are not visible to the parent data-bound control: the parent can render the child content (because controls effectively render themselves), but it cannot extract the values of these child controls to pass to an associated data source control's update, insert, or delete operation. 在資料系結案例中, 針對父系資料繫結控制項, 樣板化內容是不透明的。In data-binding scenarios, templated content is opaque to a parent data-bound control. 語法可以讓資料繫結控制項從IBindableTemplate實例內的控制項資料系結值。 BindThe Bind syntax makes it possible for the data-bound control to extract the values from a control data-bound inside an IBindableTemplate instance.

資料系結可為單向或雙向。The data binding can be one-way or two-way. (這些系結指示是由BindingDirection列舉所定義)。單向資料系結是以輸出方向執行的任何資料系結, 從資料來源控制項到資料繫結控制項;例如, 任何資料讀取案例都牽涉到單向資料系結。(These binding directions are defined by the BindingDirection enumeration.) One-way data binding is any data binding performed in an outbound direction, from data source control to data-bound control; for example, any data-reading scenario involves one-way data binding. 對於單向資料系結, 您可以在樣板化內容中使用單向資料系<%# Eval("fieldname") %>結語法 (), 而不需要使用雙向 ASP.NET 資料系結語法。For one-way data binding, you can use one-way data binding syntax (<%# Eval("fieldname") %>) inside templated content, and do not need to use two-way ASP.NET data-binding syntax. 雙向資料系結描述輸入方向的資料系結, 從資料繫結控制項到資料來源控制項。Two-way data-binding describes data-binding in the inbound direction, from the data-bound control to the data source control. 使用 ASP.NET 資料系結和資料來源控制項的自動編輯、插入和刪除案例是雙向資料系結案例。Automatic edit, insert, and delete scenarios using ASP.NET data-bound and data source controls are two-way data-binding scenarios. 這些案例使用雙向資料系結運算式 (<%# Bind("fieldname") %>)。These scenarios use two-way data-binding expressions (<%# Bind("fieldname") %>). 介面IBindableTemplate和 ASP.NET 基礎結構支援 ASP.NET 資料來源控制項與樣板化內容之間的自動、宣告式、雙向資料系結。The IBindableTemplate interface and the ASP.NET infrastructure support automatic, declarative, two-way data binding between ASP.NET data source controls and templated content. 如需有關 ASP.NET 資料系結運算式和語法的詳細資訊, 請參閱系結至資料庫和資料系結運算式總覽For more information about ASP.NET data-binding expressions and syntax, see Binding to Databases and Data-Binding Expressions Overview.

資料繫結控制項的樣板化內容最常以宣告方式定義。Templated content for data-bound controls is most often defined declaratively. 下表描述最常用來將樣板化資料系結至資料繫結控制項的程式。The following table describes the processes most commonly used to bind templated data to data-bound controls.

資料繫結控制項Data-bound control 處理序Process
DetailsView 資料繫結控制項使用資料來源控制項DataSourceID的屬性來系結至資料, 而樣板化內容則定義ItemTemplate于、 EditItemTemplateInsertItemTemplate屬性中。The data-bound control is bound to data using the DataSourceID property of the data source control, and the templated content is defined in an ItemTemplate, EditItemTemplate or InsertItemTemplate property.
GridView 資料繫結控制項使用資料來源控制項的DataSourceID屬性來系結至資料, 而樣板化內容則定義ItemTemplate于或EditItemTemplate屬性中。The data-bound control is bound to data using the DataSourceID property of the data source control, and the templated content is defined in an ItemTemplate or EditItemTemplate property. GridView控制項不支援插入作業。The GridView control does not support an insert operation.
FormView DataSourceID資料繫結控制項使用屬性系結至資料, 而樣板化內容定義ItemTemplate于、 InsertItemTemplateEditItemTemplate屬性中, 或在TemplateField物件中。The data-bound control is bound to data using the DataSourceID property, and the templated content is defined in an ItemTemplate, InsertItemTemplate, or EditItemTemplate property, or in a TemplateField object.

DataListRepeater控制項不支援自動的雙向資料系結案例。The DataList and Repeater controls do not support automatic two-way data-binding scenarios.

當已剖析系IBindableTemplate結至範本中 ASP.NET 資料來源控制項的樣板化內容時, ASP.NET 會以隱含方式建立物件。ASP.NET implicitly creates an IBindableTemplate object when templated content that binds to an ASP.NET data source control within the template is parsed. 具體而言, ASP.NET 剖析器會在剖析使用CompiledBindableTemplateBuilder ASP.NET 資料系結語法的樣板化內容, 並包含支援資料系結的 ASP.NET Web 服務器控制項時, 建立類別的實例。Specifically, the ASP.NET parser creates an instance of the CompiledBindableTemplateBuilder class when it parses templated content that uses ASP.NET data-binding syntax and contains ASP.NET Web server controls that support data binding. 這些 ASP.NET 伺服器控制項是以BindableAttribute屬性標記。These ASP.NET sever controls are marked by the BindableAttribute attribute.

介面會定義一個ExtractValues方法。 IBindableTemplateThe IBindableTemplate interface defines one method, ExtractValues. 這個方法是針對雙向資料系結所定義, 因此, 資料繫結控制項可以自動從樣板化內容中解壓縮名稱/值組, 並在執行時間將配對傳遞至資料來源控制項。This method is defined for two-way data binding, so that a data-bound control can automatically extract name/value pairs from templated content and pass the pairs to a data source control at run time. 若要讓自動資料系結成功, ExtractValues方法從樣板化內容中解壓縮的功能變數名稱, 必須符合相關聯資料來源控制項中的參數名稱。For automatic data binding to succeed, the field names extracted from the templated content by the ExtractValues method must match parameter names in an associated data source control. 控制項開發人員只ExtractValues會在其ExtractRowValues或自訂資料繫結控制項的其他類似方法中, 明確地呼叫方法。Control developers call the ExtractValues method explicitly only within their implementations of ExtractRowValues or some other similar method of a custom data-bound control.

方法

ExtractValues(Control) ExtractValues(Control) ExtractValues(Control) ExtractValues(Control)

此方法若由某個類別實作出來時,會將樣板化內容中以雙向 ASP.NET 資料繫結語法繫結的值取出,組成一連串的名稱/值組。When implemented by a class, retrieves a set of name/value pairs for values bound using two-way ASP.NET data-binding syntax within the templated content.

InstantiateIn(Control) InstantiateIn(Control) InstantiateIn(Control) InstantiateIn(Control)

當類別實作時,定義子控制項和樣板所屬的 Control 物件。When implemented by a class, defines the Control object that child controls and templates belong to. 這些子控制項依次定義在內嵌樣板內。These child controls are in turn defined within an inline template.

(Inherited from ITemplate)

適用於

另請參閱