IBindableTemplate 接口

定义

为 ASP.NET 数据绑定控件(如 DetailsViewFormView)提供一种可以自动绑定到模板化内容节中的 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 网页验证用户输入是否不包含脚本或 HTML 元素。By default, ASP.NET Web pages validate that user input does not include script or HTML elements. 有关详细信息,请参阅脚本侵入概述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>

注解

IBindableTemplate接口提供一种方法,ASP.NET 数据绑定控件(如 DetailsViewGridViewFormView )绑定到 ASP.NET 数据源控件(例如或)提供的数据( ObjectDataSource SqlDataSource 当数据绑定控件包括模板化内容时)。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 在和方法的实现中操作对象 PerformDataBinding ExtractRowValues ,但不实现其自己的 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. Bind 语法使数据绑定控件可以从实例内的控件数据绑定中提取值 IBindableTemplateThe 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 EditItemTemplate 或属性中定义 InsertItemTemplateThe 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 或属性中定义 EditItemTemplateThe 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 ,模板化内容在 ItemTemplateInsertItemTemplate 、或 EditItemTemplate 属性或对象中定义 TemplateFieldThe 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.

IBindableTemplate接口定义一个方法 ExtractValuesThe 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)

通过类来实现时,使用模板化内容中的双向 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)

当由类实现时,定义子控件和模板所属的 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.

(继承自 ITemplate)

适用于

另请参阅