FormView 类

定义

使用用户定义的模板显示数据源中单个记录的值。Displays the values of a single record from a data source using user-defined templates. 使用 FormView 控件可以编辑、删除和插入记录。The FormView control allows you to edit, delete, and insert records.

public ref class FormView : System::Web::UI::WebControls::CompositeDataBoundControl, System::Web::UI::IDataItemContainer, System::Web::UI::IPostBackEventHandler, System::Web::UI::WebControls::IDataBoundItemControl, System::Web::UI::WebControls::IPostBackContainer
[System.Web.UI.ControlValueProperty("SelectedValue")]
public class FormView : System.Web.UI.WebControls.CompositeDataBoundControl, System.Web.UI.IDataItemContainer, System.Web.UI.IPostBackEventHandler, System.Web.UI.WebControls.IDataBoundItemControl, System.Web.UI.WebControls.IPostBackContainer
type FormView = class
    inherit CompositeDataBoundControl
    interface IDataItemContainer
    interface INamingContainer
    interface IPostBackEventHandler
    interface IPostBackContainer
    interface IDataBoundItemControl
    interface IDataBoundControl
Public Class FormView
Inherits CompositeDataBoundControl
Implements IDataBoundItemControl, IDataItemContainer, IPostBackContainer, IPostBackEventHandler
继承
属性
实现

示例

下面的示例演示如何使用FormView控件显示SqlDataSource控件中的值。The following example demonstrates how to use a FormView control to display the values from a SqlDataSource 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>FormView Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormView Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID" 
        runat="server">
        
        <itemtemplate>
        
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td>
                <h3><%# Eval("FirstName") %>&nbsp;<%# Eval("LastName") %></h3>      
                <%# Eval("Title") %>        
              </td>
            </tr>
          </table>
        
        </itemtemplate>
          
        <pagersettings position="Bottom"
          mode="NextPrevious"/> 
                  
      </asp:formview>
          
      <!-- 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], [PhotoPath] From [Employees]"
        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">
<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" 
        runat="server">
        
        <itemtemplate>
        
          <table>
            <tr>
              <td>
                <asp:image id="EmployeeImage"
                  imageurl='<%# Eval("PhotoPath") %>'
                  alternatetext='<%# Eval("LastName") %>' 
                  runat="server"/>
              </td>
              <td>
                <h3><%# Eval("FirstName") %>&nbsp;<%# Eval("LastName") %></h3>      
                <%# Eval("Title") %>        
              </td>
            </tr>
          </table>
        
        </itemtemplate>
          
        <pagersettings position="Bottom"
          mode="NextPrevious"/> 
                  
      </asp:formview>
          
      <!-- 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], [PhotoPath] From [Employees]"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </form>
  </body>
</html>

下面的示例演示如何使用FormView控件来编辑现有记录。The following example demonstrates how to use a FormView control to edit existing records.

重要

此示例中的控件包含一个接受用户输入的文本框, 这是一个潜在的安全威胁。The control in this example 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>

下面的示例演示如何使用FormView控件插入新记录。The following example demonstrates how to use a FormView control to insert new records.

重要

此示例中的控件包含一个接受用户输入的文本框, 这是一个潜在的安全威胁。The control in this example 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">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>FormView InsertItemTemplate Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormView InsertItemTemplate Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        emptydatatext="No employees found."  
        runat="server">
        
        <rowstyle backcolor="LightGreen"
          wrap="false"/>
        <insertrowstyle backcolor="LightBlue"
          wrap="false"/>

        <itemtemplate>
          <table>
            <tr>
              <td rowspan="5">
                <asp:image id="CompanyLogoImage"
                  imageurl="~/Images/Logo.jpg"
                  alternatetext="Company logo"
                  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 colspan="2">
                <asp:linkbutton id="NewButton"
                  text="New"
                  commandname="New"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </itemtemplate>
        <insertitemtemplate>
          <table>
            <tr>
              <td rowspan="4">
                <asp:image id="CompanyLogoEditImage"
                  imageurl="~/Images/Logo.jpg"
                  alternatetext="Company logo"
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b><asp:Label runat="server" 
                  AssociatedControlID="FirstNameInsertTextBox" 
                  Text="Name" />:</b>
              </td>
              <td>
                <asp:textbox id="FirstNameInsertTextBox"
                  text='<%# Bind("FirstName") %>'
                  runat="server"/>
                <asp:textbox id="LastNameInsertTextBox"
                  text='<%# Bind("LastName") %>'
                  runat="server"/>
              </td>
            </tr>
            <tr>
              <td>
                <b><asp:Label runat="server" 
                  AssociatedControlID="TitleInsertTextBox" 
                  Text="Title" />:</b>
              </td>
              <td>
                <asp:textbox id="TitleInsertTextBox"
                  text='<%# Bind("Title") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="InsertButton"
                  text="Insert"
                  commandname="Insert"
                  runat="server" />
                <asp:linkbutton id="CancelButton"
                  text="Cancel"
                  commandname="Cancel"
                  runat="server" /> 
              </td>
            </tr>
          </table>       
        </insertitemtemplate> 
                  
      </asp:formview>

      <!-- 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], [PhotoPath] From [Employees]"
        insertcommand="Insert Into [Employees] ([LastName], [FirstName], [Title]) VALUES (@LastName, @FirstName, @Title)"
        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">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>FormView InsertItemTemplate Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>FormView InsertItemTemplate Example</h3>
                       
      <asp:formview id="EmployeeFormView"
        datasourceid="EmployeeSource"
        allowpaging="true"
        datakeynames="EmployeeID"
        emptydatatext="No employees found."  
        runat="server">
        
        <rowstyle backcolor="LightGreen"
          wrap="false"/>
        <insertrowstyle backcolor="LightBlue"
          wrap="false"/>

        <itemtemplate>
          <table>
            <tr>
              <td rowspan="5">
                <asp:image id="CompanyLogoImage"
                  imageurl="~/Images/Logo.jpg"
                  alternatetext="Company logo"
                  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 colspan="2">
                <asp:linkbutton id="NewButton"
                  text="New"
                  commandname="New"
                  runat="server"/> 
              </td>
            </tr>
          </table>       
        </itemtemplate>
        <insertitemtemplate>
          <table>
            <tr>
              <td rowspan="4">
                <asp:image id="CompanyLogoEditImage"
                  imageurl="~/Images/Logo.jpg"
                  alternatetext="Company logo"
                  runat="server"/>
              </td>
              <td colspan="2">
                  &nbsp; 
              </td>
            </tr>
            <tr>
              <td>
                <b><asp:Label runat="server" 
                  AssociatedControlID="FirstNameInsertTextBox" 
                  Text="Name" />:</b>
              </td>
              <td>
                <asp:textbox id="FirstNameInsertTextBox"
                  text='<%# Bind("FirstName") %>'
                  runat="server"/>
                <asp:textbox id="LastNameInsertTextBox"
                  text='<%# Bind("LastName") %>'
                  runat="server"/>
              </td>
            </tr>
            <tr>
              <td>
                <b><asp:Label runat="server" 
                  AssociatedControlID="TitleInsertTextBox" 
                  Text="Title" />:</b>
              </td>
              <td>
                <asp:textbox id="TitleInsertTextBox"
                  text='<%# Bind("Title") %>'
                  runat="server"/> 
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <asp:linkbutton id="InsertButton"
                  text="Insert"
                  commandname="Insert"
                  runat="server" />
                <asp:linkbutton id="CancelButton"
                  text="Cancel"
                  commandname="Cancel"
                  runat="server" /> 
              </td>
            </tr>
          </table>       
        </insertitemtemplate> 
                  
      </asp:formview>

      <!-- 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], [PhotoPath] From [Employees]"
        insertcommand="Insert Into [Employees] ([LastName], [FirstName], [Title]) VALUES (@LastName, @FirstName, @Title)"
        connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" 
        runat="server"/>
            
    </form>
  </body>
</html>

注解

本主题内容:In this topic:

介绍Introduction

FormView控件用于显示数据源中的单个记录。The FormView control is used to display a single record from a data source. 它类似DetailsView于控件, 只不过它显示用户定义的模板而不是行字段。It is similar to the DetailsView control, except it displays user-defined templates instead of row fields. 创建自己的模板使你可以更灵活地控制数据的显示方式。Creating your own templates gives you greater flexibility in controlling how the data is displayed. FormView控件支持以下功能:The FormView control supports the following features:

  • 绑定到数据源控件, 例如SqlDataSource和。 ObjectDataSourceBinding to data source controls, such as SqlDataSource and ObjectDataSource.

  • 内置插入功能。Built-in inserting capabilities.

  • 内置的更新和删除功能。Built-in updating and deleting capabilities.

  • 内置的分页功能。Built-in paging capabilities.

  • 以编程方式访问FormView对象模型, 以动态设置属性、处理事件等。Programmatic access to the FormView object model to dynamically set properties, handle events, and so on.

  • 通过用户定义的模板、主题和样式可自定义外观。Customizable appearance through user-defined templates, themes, and styles.

模板Templates

要使FormView控件显示内容, 需要为控件的不同部分创建模板。For the FormView control to display content, you need to create templates for the different parts of the control. 大多数模板是可选的;但是, 您必须为在其中配置控件的模式创建模板。Most templates are optional; however, you must create a template for the mode in which the control is configured. 例如, FormView支持插入记录的控件必须定义插入项模板。For example, a FormView control that supports inserting records must have an insert item template defined. 下表列出了你可以创建的不同模板。The following table lists the different templates that you can create.

模板类型Template type 说明Description
EditItemTemplate 定义当FormView控件处于编辑模式时数据行的内容。Defines the content for the data row when the FormView control is in edit mode. 此模板通常包含输入控件和命令按钮, 用户可以使用这些按钮编辑现有记录。This template usually contains input controls and command buttons with which the user can edit an existing record.
EmptyDataTemplate 定义当FormView控件绑定到不包含任何记录的数据源时所显示的空数据行的内容。Defines the content for the empty data row displayed when the FormView control is bound to a data source that does not contain any records. 此模板通常包含用于向用户发出警报, 指出数据源不包含任何记录的内容。This template usually contains content to alert the user that the data source does not contain any records.
FooterTemplate 定义脚注行的内容。Defines the content for the footer row. 此模板通常包含希望在页脚行中显示的任何其他内容。This template usually contains any additional content you would like to display in the footer row. 注意: 作为替代方法, 您可以通过设置FooterText属性来指定要在脚注行中显示的文本。Note: As an alternative, you can simply specify text to display in the footer row by setting the FooterText property.
HeaderTemplate 定义标题行的内容。Defines the content for the header row. 此模板通常包含你希望在标题行中显示的任何其他内容。This template usually contains any additional content you would like to display in the header row. 注意: 作为替代方法, 只需通过设置HeaderText属性来指定要在标题行中显示的文本。Note: As an alternative, you can simply specify text to display in the header row by setting the HeaderText property.
ItemTemplate FormView控件处于只读模式时, 定义数据行的内容。Defines the content for the data row when the FormView control is in read-only mode. 此模板通常包含用于显示现有记录的值的内容。This template usually contains content to display the values of an existing record.
InsertItemTemplate 定义数据行在FormView控件处于插入模式时的内容。Defines the content for the data row when the FormView control is in insert mode. 此模板通常包含用户可用于添加新记录的输入控件和命令按钮。This template usually contains input controls and command buttons with which the user can add a new record.
PagerTemplate 定义当分页功能处于启用状态时显示的页导航行的内容 (当AllowPaging属性设置为true时)。Defines the content for the pager row displayed when the paging feature is enabled (when the AllowPaging property is set to true). 此模板通常包含用户可在其中导航到另一记录的控件。This template usually contains controls with which the user can navigate to another record. 注意: FormView控件具有内置的页导航行用户界面 (UI)。Note: The FormView control has a built-in pager row user interface (UI). 仅当想要创建自己的自定义页导航行时, 才需要创建页导航模板。You need to create a pager template only if you want to create your own custom pager row.

若要在项模板中显示某个字段的值, 请使用数据绑定表达式。To display the value of a field in an item template, use a data binding expression. 有关数据绑定表达式的详细信息, 请参阅数据绑定表达式语法For more information on data binding expressions, see Data-Binding Expression Syntax.

编辑项模板和插入项模板中的输入控件可以通过使用双向绑定表达式绑定到数据源的字段。Input controls in the edit item template and insert item template can be bound to the fields of a data source by using a two-way binding expression. 这允许FormView控件自动提取用于更新或插入操作的输入控件的值。This allows the FormView control to automatically extract the values of the input control for an update or insert operation. 双向绑定表达式还允许编辑项模板中的输入控件自动显示原始字段值。Two-way binding expressions also allow input controls in an edit item template to automatically display the original field values. 有关双向绑定表达式的详细信息, 请参阅绑定到数据库For more information on two-way binding expressions, see Binding to Databases.

绑定到数据Binding to Data

AccessDataSource System.Collections.ArrayList System.Collections.IEnumerable SqlDataSource ObjectDataSource控件可以绑定到数据源控件 (如、或), 也可以绑定到实现接口的System.Data.DataView任何数据源集合, 如、、 FormView System.Collections.Generic.List<T>或其他集合类型。The FormView control can be bound to a data source control (such as SqlDataSource, ObjectDataSource, or AccessDataSource) or to any data source collection that implements the System.Collections.IEnumerable interface, such as System.Data.DataView, System.Collections.ArrayList, System.Collections.Generic.List<T>, or other collection types. 使用以下方法之一将FormView控件绑定到相应的数据源类型:Use one of the following methods to bind the FormView control to the appropriate data source type:

  • 若要绑定到数据源控件, 请将DataSourceID FormView控件的属性设置为数据ID源控件的值。To bind to a data source control, set the DataSourceID property of the FormView control to the ID value of the data source control. FormView控件将自动绑定到指定的数据源控件, 并可以利用数据源控件的功能来执行插入、更新、删除和分页功能。The FormView control automatically binds to the specified data source control and can take advantage of the data source control's capabilities to perform inserting, updating, deleting, and paging functionality. 这是绑定到数据的首选方法。This is the preferred method to bind to data.

  • System.Collections.IEnumerable要绑定到实现接口的数据源, 请以编程方式DataSourceFormView控件的属性设置DataBind为数据源, 然后调用方法。To bind to a data source that implements the System.Collections.IEnumerable interface, programmatically set the DataSource property of the FormView control to the data source and then call the DataBind method. 使用此方法时, FormView控件不提供内置的插入、更新、删除和分页功能。When using this method, the FormView control does not provide built-in inserting, updating, deleting, and paging functionality. 需要使用相应的事件来提供此功能。You need to provide this functionality by using the appropriate event.

有关数据绑定的详细信息, 请参阅ASP.NET 数据访问内容映射For more information on data binding, see ASP.NET Data Access Content Map.

备注

此控件可用于显示用户输入, 其中可能包括恶意客户端脚本。This control can be used to display user input, which might include malicious client script. 在应用程序中显示可执行脚本、SQL 语句或其他代码之前, 请检查从该客户端发送的任何信息。Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. 在此控件中显示值之前, 强烈建议尽可能使用 HTML 编码值。Whenever possible, it is strongly recommended that values are HTML-encoded before they are displayed in this control. ASP.NET 提供输入请求验证功能来阻止用户输入中的脚本和 HTML。ASP.NET provides an input request validation feature to block script and HTML in user input. 还提供验证服务器控件以评估用户输入。Validation server controls are also provided to assess user input. 有关详细信息, 请参阅验证控件简介For more information, see Introduction to the Validation Controls.

数据操作Data Operations

FormView控件提供了许多内置功能, 使用户可以对控件中的项进行更新、删除、插入和分页。The FormView control provides many built-in capabilities that allow the user to update, delete, insert, and page through items in the control. 当控件绑定到数据源控件时FormView , 控件可以利用数据源控件的功能, 并提供自动更新、删除、插入和分页功能。 FormViewWhen the FormView control is bound to a data source control, the FormView control can take advantage of the data source control's capabilities and provide automatic updating, deleting, inserting, and paging functionality.

备注

FormView控件可以为与其他类型的数据源的更新、删除、插入和分页操作提供支持; 但是, 您必须为这些操作的实现提供相应的事件处理程序。The FormView control can provide support for update, delete, insert, and paging operations with other types of data sources; however, you must provide an appropriate event handler with the implementation for these operations.

FormView由于控件使用模板, 因此它不提供自动生成命令按钮以执行更新、删除或插入操作的方法。Because the FormView control uses templates, it does not provide a way to automatically generate command buttons to perform updating, deleting, or inserting operations. 您必须在适当的模板中手动包含这些命令按钮。You must manually include these command buttons in the appropriate template. 控件识别某些按钮的CommandName属性设置为特定值的按钮。 FormViewThe FormView control recognizes certain buttons that have their CommandName properties set to specific values. 下表列出了FormView控件识别的命令按钮。The following table lists the command buttons that the FormView control recognizes.

ButtonButton CommandName 值CommandName value 说明Description
取消Cancel 退出"Cancel" 在更新或插入操作中用于取消操作并丢弃用户输入的值。Used in updating or inserting operations to cancel the operation and to discard the values entered by the user. 然后FormView , 该控件返回到DefaultMode由属性指定的模式。The FormView control then returns to the mode specified by the DefaultMode property.
删除Delete “Delete”"Delete" 用于删除操作以从数据源中删除所显示的记录。Used in deleting operations to delete the displayed record from the data source. ItemDeleting引发和ItemDeleted事件。Raises the ItemDeleting and ItemDeleted events.
EditEdit 编辑"Edit" 用于更新操作, 使FormView控件处于编辑模式。Used in updating operations to put the FormView control in edit mode. 为数据行显示在EditItemTemplate属性中指定的内容。The content specified in the EditItemTemplate property is displayed for the data row.
InsertInsert &"Insert" 在插入操作中用于尝试使用用户提供的值在数据源中插入新记录。Used in inserting operations to attempt to insert a new record in the data source using the values provided by the user. ItemInserting引发和ItemInserted事件。Raises the ItemInserting and ItemInserted events.
新建New 新西兰"New" 在插入操作中用于将FormView控件置于插入模式中。Used in inserting operations to put the FormView control in insert mode. 为数据行显示在InsertItemTemplate属性中指定的内容。The content specified in the InsertItemTemplate property is displayed for the data row.
页面Page 分页"Page" 用于在分页操作中表示执行分页的页导航行中的按钮。Used in paging operations to represent a button in the pager row that performs paging. 若要指定分页操作, 请将CommandArgument按钮的属性设置为 "下一步"、"上一步"、"First"、"Last" 或要导航到的页面的索引。To specify the paging operation, set the CommandArgument property of the button to "Next", "Prev", "First", "Last", or the index of the page to which to navigate. PageIndexChanging引发和PageIndexChanged事件。Raises the PageIndexChanging and PageIndexChanged events. 注意: 此类型的按钮通常仅在页导航模板中使用。Note: This type of button is typically used only in the pager template.
更新Update 时更新"Update" 用于更新操作, 尝试使用用户提供的值更新数据源中显示的记录。Used in updating operations to attempt to update the displayed record in the data source with the values provided by the user. ItemUpdating引发和ItemUpdated事件。Raises the ItemUpdating and ItemUpdated events.

与 "删除" 按钮 (它会立即删除显示的记录) 不同, 单击 "编辑" 或 "新建FormView " 按钮时, 控件将分别进入 "编辑" 或 "插入" 模式。Unlike the Delete button (which deletes the displayed record immediately), when the Edit or New button is clicked, the FormView control goes into edit or insert mode, respectively. 在编辑模式下, 将显示当前数据项EditItemTemplate的属性中包含的内容。In edit mode, the content contained in the EditItemTemplate property is displayed for the current data item. 通常, 编辑项模板的定义使 "编辑" 按钮替换为更新和 "取消" 按钮。Typically, the edit item template is defined such that the Edit button is replaced with an Update and a Cancel button. 适用于字段的数据类型 (如TextBox CheckBox或控件) 的输入控件通常还显示为用户要修改的字段值。Input controls that are appropriate for the field's data type (such as a TextBox or a CheckBox control) are also usually displayed with a field's value for the user to modify. 单击 "更新" 按钮将更新数据源中的记录, 而单击 "取消" 按钮将放弃所有更改。Clicking the Update button updates the record in the data source, while clicking the Cancel button abandons any changes.

同样, 当控件处于插入模式InsertItemTemplate时, 将为数据项显示该属性中包含的内容。Likewise, the content contained in the InsertItemTemplate property is displayed for the data item when the control is in insert mode. 插入项模板通常定义为: 将 "新建" 按钮替换为 "插入" 和 "取消" 按钮, 并为用户显示空输入控件以输入新记录的值。The insert item template is typically defined such that the New button is replaced with an Insert and a Cancel button, and empty input controls are displayed for the user to enter the values for the new record. 单击 "插入" 按钮将插入数据源中的记录, 而单击 "取消" 按钮将放弃所有更改。Clicking the Insert button inserts the record in the data source, while clicking the Cancel button abandons any changes.

FormView控件提供分页功能, 该功能允许用户导航到数据源中的其他记录。The FormView control provides a paging feature, which allows the user to navigate to other records in the data source. 启用后, 页导航行显示在包含页面FormView导航控件的控件中。When enabled, a pager row is displayed in the FormView control that contains the page navigation controls. 若要启用分页, 请AllowPaging将属性true设置为。To enable paging, set the AllowPaging property to true. 您可以通过设置PagerStyle PagerSettings和属性中包含的对象的属性来自定义页导航行。You can customize the pager row by setting the properties of objects contained in the PagerStyle and the PagerSettings property. 您可以使用PagerTemplate属性来创建自己的 UI, 而不是使用内置的页导航行 ui。Instead of using the built-in pager row UI, you can create your own UI by using the PagerTemplate property.

自定义用户界面Customizing the User Interface

您可以通过设置控件的不同FormView部分的样式属性来自定义控件的外观。You can customize the appearance of the FormView control by setting the style properties for the different parts of the control. 下表列出了不同的样式属性。The following table lists the different style properties.

Style 属性Style property 说明Description
EditRowStyle FormView控件处于编辑模式时数据行的样式设置。The style settings for the data row when the FormView control is in edit mode.
EmptyDataRowStyle 当数据源不包含任何记录时, FormView控件中显示的空数据行的样式设置。The style settings for the empty data row displayed in the FormView control when the data source does not contain any records.
FooterStyle FormView控件的脚注行的样式设置。The style settings for the footer row of the FormView control.
HeaderStyle FormView控件的标题行的样式设置。The style settings for the header row of the FormView control.
InsertRowStyle FormView控件处于插入模式时数据行的样式设置。The style settings for the data row when the FormView control is in insert mode.
PagerStyle 启用分页功能时显示在FormView控件中的页导航行的样式设置。The style settings for the pager row displayed in the FormView control when the paging feature is enabled.
RowStyle FormView控件处于只读模式时数据行的样式设置。The style settings for the data row when the FormView control is in read-only mode.

事件Events

FormView控件提供了几个可对其进行编程的事件。The FormView control provides several events that you can program against. 这使您可以在每次发生事件时运行自定义例程。This allows you to run a custom routine whenever an event occurs. 下表列出了FormView控件支持的事件。The following table lists the events supported by the FormView control.

事件Event 说明Description
ItemCommand 在单击 FormView 控件中的某个按钮时发生。Occurs when a button within a FormView control is clicked. 此事件通常用于在控件中单击按钮时执行任务。This event is often used to perform a task when a button is clicked in the control.
ItemCreated 在控件中FormViewRow创建所有对象之后发生。 FormViewOccurs after all FormViewRow objects are created in the FormView control. 此事件通常用于在记录显示之前修改记录的值。This event is often used to modify the values of a record before it is displayed.
ItemDeleted 在单击 "删除" 按钮 (其CommandName属性设置为 "Delete" 的按钮) 时, 但在FormView控件从数据源中删除记录之后发生。Occurs when a Delete button (a button with its CommandName property set to "Delete") is clicked, but after the FormView control deletes the record from the data source. 此事件通常用于检查删除操作的结果。This event is often used to check the results of the delete operation.
ItemDeleting 在单击 "删除" 按钮时, 但在FormView控件从数据源中删除记录之前发生。Occurs when a Delete button is clicked, but before the FormView control deletes the record from the data source. 此事件通常用于取消删除操作。This event is often used to cancel the delete operation.
ItemInserted 单击 "插入" 按钮 (其CommandName属性设置为 "插入" 的按钮) 时, 但在FormView控件插入记录后发生。Occurs when an Insert button (a button with its CommandName property set to "Insert") is clicked, but after the FormView control inserts the record. 此事件通常用于检查插入操作的结果。This event is often used to check the results of the insert operation.
ItemInserting 当单击 "插入" 按钮时, 但在FormView控件插入记录之前发生。Occurs when an Insert button is clicked, but before the FormView control inserts the record. 此事件通常用于取消插入操作。This event is often used to cancel the insert operation.
ItemUpdated 在单击 "更新" 按钮 (其CommandName属性设置为 "Update" 的按钮) 时, 但在FormView控件更新行后发生。Occurs when an Update button (a button with its CommandName property set to "Update") is clicked, but after the FormView control updates the row. 此事件通常用于检查更新操作的结果。This event is often used to check the results of the update operation.
ItemUpdating 当单击 "更新" 按钮时, 但在FormView控件更新记录之前发生。Occurs when an Update button is clicked, but before the FormView control updates the record. 此事件通常用于取消更新操作。This event is often used to cancel the update operation.
ModeChanged FormView控件更改模式 (用于编辑、插入或只读模式) 后发生。Occurs after the FormView control changes modes (to edit, insert, or read-only mode). 此事件通常用于在FormView控件更改模式时执行任务。This event is often used to perform a task when the FormView control changes modes.
ModeChanging FormView控件更改模式 (用于编辑、插入或只读模式) 之前发生。Occurs before the FormView control changes modes (to edit, insert, or read-only mode). 此事件通常用于取消模式更改。This event is often used to cancel a mode change.
PageIndexChanged 在单击某一页导航按钮时,但在 FormView 控件处理分页操作之后发生。Occurs when one of the pager buttons is clicked, but after the FormView control handles the paging operation. 此事件通常在用户导航至控件中的其他记录后需要执行任务时使用。This event is commonly used when you need to perform a task after the user navigates to a different record in the control.
PageIndexChanging 在单击某一页导航按钮时,但在 FormView 控件处理分页操作之前发生。Occurs when one of the pager buttons is clicked, but before the FormView control handles the paging operation. 此事件通常用于取消分页操作。This event is often used to cancel the paging operation.

可访问性Accessibility

有关如何配置此控件以生成符合辅助功能标准的标记的信息, 请参阅Visual Studio 中的辅助功能和 ASP.NETASP.NET 控件和辅助功能For information about how to configure this control so that it generates markup that conforms to accessibility standards, see Accessibility in Visual Studio and ASP.NET and ASP.NET Controls and Accessibility.

应用 CSS 样式Applying CSS Styles

FormView控件使您可以在标记中指定 CSS 样式规则。The FormView control lets you specify CSS style rules in markup. 如果使用模板来自定义FormView控件的外观, 则可以在模板的标记中指定 CSS 样式。If you use templates to customize the appearance of the FormView control, you can specify CSS styles in the markup in the templates. 在这种情况下, 不需要额外的外部表。In that case, no extra outer table is required. 您可以通过将RenderOuterTable属性设置为来false阻止呈现该表。You can prevent the table from being rendered by setting the RenderOuterTable property to false.

声明性语法Declarative Syntax

<asp:FormView  
    AccessKey="string"  
    AllowPaging="True|False"  
    BackColor="color name|#dddddd"  
    BackImageUrl="uri"  
    BorderColor="color name|#dddddd"  
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|  
        Inset|Outset"  
    BorderWidth="size"  
    Caption="string"  
    CaptionAlign="NotSet|Top|Bottom|Left|Right"  
    CellPadding="integer"  
    CellSpacing="integer"  
    CssClass="string"  
    DataKeyNames="string"  
    DataMember="string"  
    DataSource="string"  
    DataSourceID="string"  
    DefaultMode="ReadOnly|Edit|Insert"  
    EmptyDataText="string"  
    Enabled="True|False"  
    EnableTheming="True|False"  
    EnableViewState="True|False"  
    Font-Bold="True|False"  
    Font-Italic="True|False"  
    Font-Names="string"  
    Font-Overline="True|False"  
    Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|  
        Large|X-Large|XX-Large"  
    Font-Strikeout="True|False"  
    Font-Underline="True|False"  
    FooterText="string"  
    ForeColor="color name|#dddddd"  
    GridLines="None|Horizontal|Vertical|Both"  
    HeaderText="string"  
    Height="size"  
    HorizontalAlign="NotSet|Left|Center|Right|Justify"  
    ID="string"  
    OnDataBinding="DataBinding event handler"  
    OnDataBound="DataBound event handler"  
    OnDisposed="Disposed event handler"  
    OnInit="Init event handler"  
    OnItemCommand="ItemCommand event handler"  
    OnItemCreated="ItemCreated event handler"  
    OnItemDeleted="ItemDeleted event handler"  
    OnItemDeleting="ItemDeleting event handler"  
    OnItemInserted="ItemInserted event handler"  
    OnItemInserting="ItemInserting event handler"  
    OnItemUpdated="ItemUpdated event handler"  
    OnItemUpdating="ItemUpdating event handler"  
    OnLoad="Load event handler"  
    OnModeChanged="ModeChanged event handler"  
    OnModeChanging="ModeChanging event handler"  
    OnPageIndexChanged="PageIndexChanged event handler"  
    OnPageIndexChanging="PageIndexChanging event handler"  
    OnPreRender="PreRender event handler"  
    OnUnload="Unload event handler"  
    PageIndex="integer"  
    PagerSettings-FirstPageImageUrl="uri"  
    PagerSettings-FirstPageText="string"  
    PagerSettings-LastPageImageUrl="uri"  
    PagerSettings-LastPageText="string"  
    PagerSettings-Mode="NextPrevious|Numeric|NextPreviousFirstLast|  
        NumericFirstLast"  
    PagerSettings-NextPageImageUrl="uri"  
    PagerSettings-NextPageText="string"  
    PagerSettings-PageButtonCount="integer"  
    PagerSettings-Position="Bottom|Top|TopAndBottom"  
    PagerSettings-PreviousPageImageUrl="uri"  
    PagerSettings-PreviousPageText="string"  
    PagerSettings-Visible="True|False"  
    RenderTable="True|False"  
    runat="server"  
    SkinID="string"  
    Style="string"  
    TabIndex="integer"  
    ToolTip="string"  
    Visible="True|False"  
    Width="size"  
>  
        <EditItemTemplate>  
            <!-- child controls -->  
        </EditItemTemplate>  
        <EditRowStyle />  
        <EmptyDataRowStyle />  
        <EmptyDataTemplate>  
            <!-- child controls -->  
        </EmptyDataTemplate>  
        <FooterStyle />  
        <FooterTemplate>  
            <!-- child controls -->  
        </FooterTemplate>  
        <HeaderStyle />  
        <HeaderTemplate>  
            <!-- child controls -->  
        </HeaderTemplate>  
        <InsertItemTemplate>  
            <!-- child controls -->  
        </InsertItemTemplate>  
        <InsertRowStyle />  
        <ItemTemplate>  
            <!-- child controls -->  
        </ItemTemplate>  
        <PagerSettings  
            FirstPageImageUrl="uri"  
            FirstPageText="string"  
            LastPageImageUrl="uri"  
            LastPageText="string"  
            Mode="NextPrevious|Numeric|NextPreviousFirstLast|  
                NumericFirstLast"  
            NextPageImageUrl="uri"  
            NextPageText="string"  
            OnPropertyChanged="PropertyChanged event handler"  
            PageButtonCount="integer"  
            Position="Bottom|Top|TopAndBottom"  
            PreviousPageImageUrl="uri"  
            PreviousPageText="string"  
            Visible="True|False"  
        />  
        <PagerStyle />  
        <PagerTemplate>  
            <!-- child controls -->  
        </PagerTemplate>  
        <RowStyle />  
</asp:FormView>  

构造函数

FormView()

初始化 FormView 类的新实例。Initializes a new instance of the FormView class.

属性

AccessKey

获取或设置使您得以快速导航到 Web 服务器控件的访问键。Gets or sets the access key that allows you to quickly navigate to the Web server control.

(继承自 WebControl)
Adapter

获取控件的浏览器特定适配器。Gets the browser-specific adapter for the control.

(继承自 Control)
AllowPaging

获取或设置一个值,该值指示是否启用分页功能。Gets or sets a value indicating whether the paging feature is enabled.

AppRelativeTemplateSourceDirectory

获取或设置包含该控件的 PageUserControl 对象的应用程序相对虚拟目录。Gets or sets the application-relative virtual directory of the Page or UserControl object that contains this control.

(继承自 Control)
Attributes

获取与控件的特性不对应的任意特性(只用于呈现)的集合。Gets the collection of arbitrary attributes (for rendering only) that do not correspond to properties on the control.

(继承自 WebControl)
BackColor

获取或设置 Web 服务器控件的背景色。Gets or sets the background color of the Web server control.

(继承自 WebControl)
BackImageUrl

获取或设置要在 FormView 控件的背景中显示的图像的 URL。Gets or sets the URL to an image to display in the background of a FormView control.

BindingContainer

获取包含该控件的数据绑定的控件。Gets the control that contains this control's data binding.

(继承自 Control)
BorderColor

获取或设置 Web 控件的边框颜色。Gets or sets the border color of the Web control.

(继承自 WebControl)
BorderStyle

获取或设置 Web 服务器控件的边框样式。Gets or sets the border style of the Web server control.

(继承自 WebControl)
BorderWidth

获取或设置 Web 服务器控件的边框宽度。Gets or sets the border width of the Web server control.

(继承自 WebControl)
BottomPagerRow

获取 FormViewRow 对象,该对象表示在 FormView 控件底部显示的页导航行。Gets the FormViewRow object that represents the pager row displayed at the bottom of the FormView control.

Caption

获取或设置要在 FormView 控件的 HTML 标题元素中呈现的文本。Gets or sets the text to render in an HTML caption element in a FormView control. 提供此属性的目的是使辅助技术设备的用户更易于访问控件。This property is provided to make the control more accessible to users of assistive technology devices.

CaptionAlign

获取或设置 FormView 控件中的 HTML 标题元素的水平或垂直位置。Gets or sets the horizontal or vertical position of the HTML caption element in a FormView control. 提供此属性的目的是使辅助技术设备的用户更易于访问控件。This property is provided to make the control more accessible to users of assistive technology devices.

CellPadding

获取或设置单元格的内容和单元格的边框之间的空间量。Gets or sets the amount of space between the contents of a cell and the cell's border.

CellSpacing

获取或设置单元格间的空间量。Gets or sets the amount of space between cells.

ChildControlsCreated

获取一个值,该值指示是否已创建服务器控件的子控件。Gets a value that indicates whether the server control's child controls have been created.

(继承自 Control)
ClientID

获取由 ASP.NET 生成的 HTML 标记的控件 ID。Gets the control ID for HTML markup that is generated by ASP.NET.

(继承自 Control)
ClientIDMode

获取或设置用于生成 ClientID 属性值的算法。Gets or sets the algorithm that is used to generate the value of the ClientID property.

(继承自 Control)
ClientIDSeparator

获取一个字符值,该值表示 ClientID 属性中使用的分隔符字符。Gets a character value representing the separator character used in the ClientID property.

(继承自 Control)
Context

为当前 Web 请求获取与服务器控件关联的 HttpContext 对象。Gets the HttpContext object associated with the server control for the current Web request.

(继承自 Control)
Controls

获取复合数据绑定控件内的子控件的集合。Gets a collection of the child controls within the composite data-bound control.

(继承自 CompositeDataBoundControl)
ControlStyle

获取 Web 服务器控件的样式。Gets the style of the Web server control. 此属性主要由控件开发人员使用。This property is used primarily by control developers.

(继承自 WebControl)
ControlStyleCreated

获取一个值,该值指示是否已为 Style 属性创建了 ControlStyle 对象。Gets a value indicating whether a Style object has been created for the ControlStyle property. 此属性主要由控件开发人员使用。This property is primarily used by control developers.

(继承自 WebControl)
CssClass

获取或设置由 Web 服务器控件在客户端呈现的级联样式表 (CSS) 类。Gets or sets the Cascading Style Sheet (CSS) class rendered by the Web server control on the client.

(继承自 WebControl)
CurrentMode

获取 FormView 控件的当前数据输入模式。Gets the current data-entry mode of the FormView control.

DataItem

获取绑定到 FormView 控件的数据项。Gets the data item bound to the FormView control.

DataItemContainer

如果命名容器实现 IDataItemContainer,则获取对命名容器的引用。Gets a reference to the naming container if the naming container implements IDataItemContainer.

(继承自 Control)
DataItemCount

获取数据源中的数据项的数目。Gets the number of data items in the data source.

DataItemIndex

获取从数据源绑定到 FormView 控件的数据项的索引。Gets the index of the data item bound to the FormView control from the data source.

DataKey

获取一个 DataKey 对象,该对象表示所显示的记录的主键。Gets a DataKey object that represents the primary key of the displayed record.

DataKeyNames

获取或设置一个数组,该数组包含数据源的键字段的名称。Gets or sets an array that contains the names of the key fields for the data source.

DataKeysContainer

如果命名容器实现 IDataKeysControl,则获取对命名容器的引用。Gets a reference to the naming container if the naming container implements IDataKeysControl.

(继承自 Control)
DataMember

当数据源包含多个不同的数据项列表时,获取或设置数据绑定控件绑定到的数据列表的名称。Gets or sets the name of the list of data that the data-bound control binds to, in cases where the data source contains more than one distinct list of data items.

(继承自 DataBoundControl)
DataSource

获取或设置对象,数据绑定控件从该对象中检索其数据项列表。Gets or sets the object from which the data-bound control retrieves its list of data items.

(继承自 BaseDataBoundControl)
DataSourceID

获取或设置控件的 ID,数据绑定控件从该控件中检索其数据项列表。Gets or sets the ID of the control from which the data-bound control retrieves its list of data items.

(继承自 DataBoundControl)
DataSourceObject

获取一个对象,该对象实现 IDataSource 接口,以便提供对该对象的数据内容的访问。Gets an object that implements the IDataSource interface, which provides access to the object's data content.

(继承自 DataBoundControl)
DefaultMode

获取或设置数据输入模式,FormView 控件在更新、插入或取消操作后返回到该模式。Gets or sets the data-entry mode to which the FormView control returns after an update, insert, or cancel operation.

DeleteMethod

获取或设置控件执行删除操作时调用的页面上的方法的名称。Gets or sets the name of the method on the page that is called when the control performs a delete operation.

DesignMode

获取一个值,该值指示是否正在使用设计图面上的一个控件。Gets a value indicating whether a control is being used on a design surface.

(继承自 Control)
EditItemTemplate

获取或设置编辑模式中项的自定义内容。Gets or sets the custom content for an item in edit mode.

EditRowStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置 FormView 控件处于编辑模式时数据行的外观。Gets a reference to the TableItemStyle object that allows you to set the appearance of the data row when a FormView control is in edit mode.

EmptyDataRowStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置在绑定到 FormView 控件的数据源不包含任何记录时所显示的空数据行的外观。Gets a reference to the TableItemStyle object that allows you to set the appearance of the empty data row displayed when the data source bound to a FormView control does not contain any records.

EmptyDataTemplate

获取或设置在 FormView 控件绑定到不包含任何记录的数据源时所呈现的空数据行的用户定义内容。Gets or sets the user-defined content for the empty data row rendered when a FormView control is bound to a data source that does not contain any records.

EmptyDataText

获取或设置在 FormView 控件绑定到不包含任何记录的数据源时所呈现的空数据行中显示的文本。Gets or sets the text to display in the empty data row rendered when a FormView control is bound to a data source that does not contain any records.

Enabled

获取或设置一个值,该值指示是否启用 Web 服务器控件。Gets or sets a value indicating whether the Web server control is enabled.

(继承自 WebControl)
EnableModelValidation

获取或设置一个值,该值指示验证程序控件是否会处理在插入或更新操作过程中出现的异常。Gets or sets a value that indicates whether a validator control will handle exceptions that occur during insert or update operations.

EnableTheming

获取或设置一个值,该值指示主题是否应用于该控件。Gets or sets a value indicating whether themes apply to this control.

(继承自 WebControl)
EnableViewState

获取或设置一个值,该值指示服务器控件是否向发出请求的客户端保持自己的视图状态以及它所包含的任何子控件的视图状态。Gets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client.

(继承自 Control)
Events

获取控件的事件处理程序委托列表。Gets a list of event handler delegates for the control. 此属性是只读的。This property is read-only.

(继承自 Control)
Font

获取与 Web 服务器控件关联的字体属性。Gets the font properties associated with the Web server control.

(继承自 WebControl)
FooterRow

获取表示 FormViewRow 控件中的脚注行的 FormView 对象。Gets the FormViewRow object that represents the footer row in a FormView control.

FooterStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置 FormView 控件中的脚注行的外观。Gets a reference to the TableItemStyle object that allows you to set the appearance of the footer row in a FormView control.

FooterTemplate

获取或设置 FormView 控件中的脚注行的用户定义内容。Gets or sets the user-defined content for the footer row in a FormView control.

FooterText

获取或设置要在 FormView 控件的脚注行中显示的文本。Gets or sets the text to display in the footer row of a FormView control.

ForeColor

获取或设置 Web 服务器控件的前景色(通常是文本颜色)。Gets or sets the foreground color (typically the color of the text) of the Web server control.

(继承自 WebControl)
GridLines

获取或设置 FormView 控件的网格线样式。Gets or sets the gridline style for a FormView control.

HasAttributes

获取一个值,该值指示控件是否具有特性集。Gets a value indicating whether the control has attributes set.

(继承自 WebControl)
HasChildViewState

获取一个值,该值指示当前服务器控件的子控件是否具有任何已保存的视图状态设置。Gets a value indicating whether the current server control's child controls have any saved view-state settings.

(继承自 Control)
HeaderRow

获取表示 FormViewRow 控件中的标题行的 FormView 对象。Gets the FormViewRow object that represents the header row in a FormView control.

HeaderStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置 FormView 控件中的标题行的外观。Gets a reference to the TableItemStyle object that allows you to set the appearance of the header row in a FormView control.

HeaderTemplate

获取或设置 FormView 控件中的标题行的用户定义内容。Gets or sets the user-defined content for the header row in a FormView control.

HeaderText

获取或设置要在 FormView 控件的标题行中显示的文本。Gets or sets the text to display in the header row of a FormView control.

Height

获取或设置 Web 服务器控件的高度。Gets or sets the height of the Web server control.

(继承自 WebControl)
HorizontalAlign

获取或设置 FormView 控件在页面上的水平对齐方式。Gets or sets the horizontal alignment of a FormView control on the page.

ID

获取或设置分配给服务器控件的编程标识符。Gets or sets the programmatic identifier assigned to the server control.

(继承自 Control)
IdSeparator

获取用于分隔控件标识符的字符。Gets the character used to separate control identifiers.

(继承自 Control)
Initialized

获取一个值,该值指示数据绑定控件是否已经初始化。Gets a value indicating whether the data-bound control has been initialized.

(继承自 BaseDataBoundControl)
InsertItemTemplate

获取或设置插入模式中项的自定义内容。Gets or sets the custom content for an item in insert mode.

InsertMethod

获取或设置控件执行插入操作时调用的页面上的方法的名称。Gets or sets the name of the method on the page that is called when the control performs an insert operation.

InsertRowStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置在 FormView 控件处于插入模式时该控件中的数据行的外观。Gets a reference to the TableItemStyle object that allows you to set the appearance of the data row in a FormView control when the control is in insert mode.

IsBoundUsingDataSourceID

获取指示是否设置 DataSourceID 属性的值。Gets a value indicating whether the DataSourceID property is set.

(继承自 BaseDataBoundControl)
IsChildControlStateCleared

获取一个值,该值指示该控件中包含的控件是否具有控件状态。Gets a value indicating whether controls contained within this control have control state.

(继承自 Control)
IsDataBindingAutomatic

获取一个值,该值指示数据绑定功能是否是自动的。Gets a value that indicates whether data binding is automatic.

(继承自 BaseDataBoundControl)
IsEnabled

获取一个值,该值指示是否启用控件。Gets a value indicating whether the control is enabled.

(继承自 WebControl)
IsTrackingViewState

获取一个值,用于指示服务器控件是否会将更改保存到其视图状态中。Gets a value that indicates whether the server control is saving changes to its view state.

(继承自 Control)
IsUsingModelBinders

获取一个值,该值指示是否使用模型绑定。Gets a value that indicates whether model binding is in use.

(继承自 CompositeDataBoundControl)
IsViewStateEnabled

获取一个值,该值指示是否为该控件启用了视图状态。Gets a value indicating whether view state is enabled for this control.

(继承自 Control)
ItemTemplate

获取或设置在 FormView 控件处于只读模式时该控件中的数据行的自定义内容。Gets or sets the custom content for the data row in a FormView control when the control is in read-only mode.

ItemType

获取或设置强类型化数据绑定的数据项目类型的名称。Gets or sets the name of the data item type for strongly typed data binding.

(继承自 DataBoundControl)
LoadViewStateByID

获取一个值,该值指示控件是否通过 ID 而不是索引参与加载其视图状态。Gets a value indicating whether the control participates in loading its view state by ID instead of index.

(继承自 Control)
NamingContainer

获取对服务器控件的命名容器的引用,此引用创建唯一的命名空间,以区分具有相同 ID 属性值的服务器控件。Gets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same ID property value.

(继承自 Control)
Page

获取对包含服务器控件的 Page 实例的引用。Gets a reference to the Page instance that contains the server control.

(继承自 Control)
PageCount

获取显示数据源中的所有记录所需要的总页数。Gets the total number of pages required to display every record in the data source.

PageIndex

获取或设置所显示的页的索引。Gets or sets the index of the displayed page.

PagerSettings

获取一个对 PagerSettings 对象的引用,使用该对象可以设置 FormView 控件中的页导航按钮的属性。Gets a reference to the PagerSettings object that allows you to set the properties of the pager buttons in a FormView control.

PagerStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置 FormView 控件中的页导航行的外观。Gets a reference to the TableItemStyle object that allows you to set the appearance of the pager row in a FormView control.

PagerTemplate

获取或设置 FormView 控件中页导航行的自定义内容。Gets or sets the custom content for the pager row in a FormView control.

Parent

获取对页 UI 层次结构中服务器控件的父控件的引用。Gets a reference to the server control's parent control in the page control hierarchy.

(继承自 Control)
RenderingCompatibility

获取一个值,该值指定呈现的 HTML 将与之兼容的 ASP.NET 版本。Gets a value that specifies the ASP.NET version that rendered HTML will be compatible with.

(继承自 Control)
RenderOuterTable

获取或设置一个值,该值指示控件是否将呈现的 HTML 包含在 table 元素中,以便应用内联样式。Gets or sets a value that indicates whether the control encloses rendered HTML in a table element in order to apply inline styles.

RequiresDataBinding

获取或设置一个值,该值指示是否应调用 DataBind() 方法。Gets or sets a value indicating whether the DataBind() method should be called.

(继承自 BaseDataBoundControl)
Row

获取表示 FormViewRow 控件中的数据行的 FormView 对象。Gets the FormViewRow object that represents the data row in a FormView control.

RowStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置在 FormView 控件处于只读模式时该控件中的数据行的外观。Gets a reference to the TableItemStyle object that allows you to set the appearance of the data row in a FormView control when the control is in read-only mode.

SelectArguments

获取数据绑定控件从数据源控件检索数据时使用的 DataSourceSelectArguments 对象。Gets a DataSourceSelectArguments object that the data-bound control uses when retrieving data from a data source control.

(继承自 DataBoundControl)
SelectedValue

获取 FormView 控件中的当前记录的数据键值。Gets the data key value of the current record in a FormView control.

SelectMethod

为了读取数据要调用的方法的名称。The name of the method to call in order to read data.

(继承自 DataBoundControl)
Site

获取容器信息,该容器在呈现于设计图面上时承载当前控件。Gets information about the container that hosts the current control when rendered on a design surface.

(继承自 Control)
SkinID

获取或设置要应用于控件的外观。Gets or sets the skin to apply to the control.

(继承自 WebControl)
Style

获取将在 Web 服务器控件的外部标记上呈现为样式特性的文本特性的集合。Gets a collection of text attributes that will be rendered as a style attribute on the outer tag of the Web server control.

(继承自 WebControl)
SupportsDisabledAttribute

获取一个值,该值指示在控件的 IsEnabled 属性为 disabled 时,控件是否应将呈现的 HTML 元素的 false 特性设置为“disabled”。Gets a value that indicates whether the control should set the disabled attribute of the rendered HTML element to "disabled" when the control's IsEnabled property is false.

(继承自 BaseDataBoundControl)
TabIndex

获取或设置 Web 服务器控件的选项卡索引。Gets or sets the tab index of the Web server control.

(继承自 WebControl)
TagKey

获取 HtmlTextWriterTag 控件的 FormView 值。Gets the HtmlTextWriterTag value for the FormView control.

TagName

获取控件标记的名称。Gets the name of the control tag. 此属性主要由控件开发人员使用。This property is used primarily by control developers.

(继承自 WebControl)
TemplateControl

获取或设置对包含该控件的模板的引用。Gets or sets a reference to the template that contains this control.

(继承自 Control)
TemplateSourceDirectory

获取包含当前服务器控件的 PageUserControl 的虚拟目录。Gets the virtual directory of the Page or UserControl that contains the current server control.

(继承自 Control)
ToolTip

获取或设置当鼠标指针悬停在 Web 服务器控件上时显示的文本。Gets or sets the text displayed when the mouse pointer hovers over the Web server control.

(继承自 WebControl)
TopPagerRow

获取表示在 FormViewRow 控件顶部显示的页导航行的 FormView 对象。Gets the FormViewRow object that represents the pager row displayed at the top of a FormView control.

UniqueID

获取服务器控件的唯一的、以分层形式限定的标识符。Gets the unique, hierarchically qualified identifier for the server control.

(继承自 Control)
UpdateMethod

获取或设置控件执行更新操作时调用的页面上的方法的名称。Gets or sets the name of the method on the page that is called when the control performs an update operation.

ValidateRequestMode

获取或设置指示控件是否检查来自浏览器的客户端输入是否具有潜在危险值的值。Gets or sets a value that indicates whether the control checks client input from the browser for potentially dangerous values.

(继承自 Control)
ViewState

获取状态信息的字典,这些信息使您可以在同一页的多个请求间保存和还原服务器控件的视图状态。Gets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page.

(继承自 Control)
ViewStateIgnoresCase

获取一个值,该值指示 StateBag 对象是否不区分大小写。Gets a value that indicates whether the StateBag object is case-insensitive.

(继承自 Control)
ViewStateMode

获取或设置此控件的视图状态模式。Gets or sets the view-state mode of this control.

(继承自 Control)
Visible

获取或设置一个值,该值指示服务器控件是否作为 UI 呈现在页上。Gets or sets a value that indicates whether a server control is rendered as UI on the page.

(继承自 Control)
Width

获取或设置 Web 服务器控件的宽度。Gets or sets the width of the Web server control.

(继承自 WebControl)

方法

AddAttributesToRender(HtmlTextWriter)

将需要呈现的 HTML 特性和样式添加到指定的 HtmlTextWriterTag 中。Adds HTML attributes and styles that need to be rendered to the specified HtmlTextWriterTag. 此方法主要由控件开发人员使用。This method is used primarily by control developers.

(继承自 WebControl)
AddedControl(Control, Int32)

在子控件添加到 Control 对象的 Controls 集合后调用。Called after a child control is added to the Controls collection of the Control object.

(继承自 Control)
AddParsedSubObject(Object)

通知服务器控件,分析了一个元素(XML 或 HTML),并将该元素添加到服务器控件的 ControlCollection 对象中。Notifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's ControlCollection object.

(继承自 Control)
ApplyStyle(Style)

将指定样式的所有非空白元素复制到 Web 控件,覆盖控件的所有现有的样式元素。Copies any nonblank elements of the specified style to the Web control, overwriting any existing style elements of the control. 此方法主要由控件开发人员使用。This method is primarily used by control developers.

(继承自 WebControl)
ApplyStyleSheetSkin(Page)

将页样式表中定义的样式属性应用到控件。Applies the style properties defined in the page style sheet to the control.

(继承自 Control)
BeginRenderTracing(TextWriter, Object)

开始输出数据的设计时追踪。Begins design-time tracing of rendering data.

(继承自 Control)
BuildProfileTree(String, Boolean)

收集有关服务器控件的信息并将该信息发送到 Trace 属性,在启用页的跟踪功能时将显示该属性。Gathers information about the server control and delivers it to the Trace property to be displayed when tracing is enabled for the page.

(继承自 Control)
ChangeMode(FormViewMode)

FormView 控件切换到指定的数据输入模式。Switches the FormView control to the specified data-entry mode.

ClearCachedClientID()

将缓存的 ClientID 值设置为 nullSets the cached ClientID value to null.

(继承自 Control)
ClearChildControlState()

删除服务器控件的子控件的控件状态信息。Deletes the control-state information for the server control's child controls.

(继承自 Control)
ClearChildState()

删除服务器控件的所有子控件的视图状态和控件状态信息。Deletes the view-state and control-state information for all the server control's child controls.

(继承自 Control)
ClearChildViewState()

删除服务器控件的所有子控件的视图状态信息。Deletes the view-state information for all the server control's child controls.

(继承自 Control)
ClearEffectiveClientIDMode()

将当前控件实例和任何子控件的 ClientIDMode 属性设置为 InheritSets the ClientIDMode property of the current control instance and of any child controls to Inherit.

(继承自 Control)
ConfirmInitState()

设置数据绑定控件的初始化状态。Sets the initialized state of the data-bound control.

(继承自 BaseDataBoundControl)
CopyBaseAttributes(WebControl)

Style 对象未封装的属性从指定的 Web 服务器控件复制到从中调用此方法的 Web 服务器控件。Copies the properties not encapsulated by the Style object from the specified Web server control to the Web server control that this method is called from. 此方法主要由控件开发人员使用。This method is used primarily by control developers.

(继承自 WebControl)
CreateChildControls()

基于存储在视图状态中的值创建用来呈现复合数据绑定控件的控件层次结构。Creates the control hierarchy that is used to render a composite data-bound control based on the values that are stored in view state.

(继承自 CompositeDataBoundControl)
CreateChildControls(IEnumerable, Boolean)

用指定数据源创建用于呈现 FormView 控件的控件层次结构。Creates the control hierarchy used to render the FormView control with the specified data source.

CreateControlCollection()

创建一个新 ControlCollection 对象来保存服务器控件的子控件(包括文本控件和服务器控件)。Creates a new ControlCollection object to hold the child controls (both literal and server) of the server control.

(继承自 Control)
CreateControlStyle()

创建 FormView 控件的默认表样式对象。Creates a default table style object for the FormView control.

CreateDataSourceSelectArguments()

创建 DataSourceSelectArguments 对象,该对象包含传递到数据源以进行处理的参数。Creates the DataSourceSelectArguments object that contains the arguments that are passed to the data source for processing.

CreateRow(Int32, DataControlRowType, DataControlRowState)

使用指定项索引、行类型和行状态创建 FormViewRow 对象。Creates a FormViewRow object using the specified item index, row type, and row state.

CreateTable()

FormView 控件创建包含表。Creates the containing table for the FormView control.

DataBind()

将数据源绑定到 FormView 控件。Binds the data source to the FormView control.

DataBind(Boolean)

将数据源绑定到调用的服务器控件及其所有子控件,同时可以选择引发 DataBinding 事件。Binds a data source to the invoked server control and all its child controls with an option to raise the DataBinding event.

(继承自 Control)
DataBindChildren()

将数据源绑定到服务器控件的子控件。Binds a data source to the server control's child controls.

(继承自 Control)
DeleteItem()

从数据源中删除 FormView 控件中的当前记录。Deletes the current record in the FormView control from the data source.

Dispose()

使服务器控件得以在从内存中释放之前执行最后的清理操作。Enables a server control to perform final clean up before it is released from memory.

(继承自 Control)
EndRenderTracing(TextWriter, Object)

结束输出数据的设计时追踪。Ends design-time tracing of rendering data.

(继承自 Control)
EnsureChildControls()

确定服务器控件是否包含子控件。Determines whether the server control contains child controls. 如果不包含,则创建子控件。If it does not, it creates child controls.

(继承自 Control)
EnsureDataBound()

请确保 FormView 控件在适当时绑定到数据。Makes certain that the FormView control is bound to data when appropriate.

EnsureID()

为尚未分配标识符的控件创建标识符。Creates an identifier for controls that do not have an identifier assigned.

(继承自 Control)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
ExtractRowValues(IOrderedDictionary, Boolean)

检索在数据行内声明的每个字段的值,并将这些值存储在指定的 IOrderedDictionary 对象中。Retrieves the values of each field declared within the data row and stores them in the specified IOrderedDictionary object.

FindControl(String)

在当前的命名容器中搜索带指定 id 参数的服务器控件。Searches the current naming container for a server control with the specified id parameter.

(继承自 Control)
FindControl(String, Int32)

使用指定的 idpathOffset 参数(该参数有助于搜索)中指定的整数在当前命名容器中搜索服务器控件。Searches the current naming container for a server control with the specified id and an integer, specified in the pathOffset parameter, which aids in the search. 不应重写此版本的 FindControl 方法。You should not override this version of the FindControl method.

(继承自 Control)
Focus()

为控件设置输入焦点。Sets input focus to a control.

(继承自 Control)
GetData()

检索数据绑定控件用于执行数据操作的 DataSourceView 对象。Retrieves a DataSourceView object that the data-bound control uses to perform data operations.

(继承自 DataBoundControl)
GetDataSource()

检索与数据绑定控件关联的 IDataSource 接口(如果有)。Retrieves the IDataSource interface that the data-bound control is associated with, if any.

(继承自 DataBoundControl)
GetDesignModeState()

获取控件的设计时数据。Gets design-time data for a control.

(继承自 Control)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetRouteUrl(Object)

获取与一组路由参数对应的 URL。Gets the URL that corresponds to a set of route parameters.

(继承自 Control)
GetRouteUrl(RouteValueDictionary)

获取与一组路由参数对应的 URL。Gets the URL that corresponds to a set of route parameters.

(继承自 Control)
GetRouteUrl(String, Object)

获取与一组路由参数以及某个路由名称对应的 URL。Gets the URL that corresponds to a set of route parameters and a route name.

(继承自 Control)
GetRouteUrl(String, RouteValueDictionary)

获取与一组路由参数以及某个路由名称对应的 URL。Gets the URL that corresponds to a set of route parameters and a route name.

(继承自 Control)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
GetUniqueIDRelativeTo(Control)

返回指定控件的 UniqueID 属性的前缀部分。Returns the prefixed portion of the UniqueID property of the specified control.

(继承自 Control)
HasControls()

确定服务器控件是否包含任何子控件。Determines if the server control contains any child controls.

(继承自 Control)
HasEvents()

返回一个值,该值指示是否为控件或任何子控件注册事件。Returns a value indicating whether events are registered for the control or any child controls.

(继承自 Control)
InitializePager(FormViewRow, PagedDataSource)

FormView 控件创建页导航行。Creates the pager row for the FormView control.

InitializeRow(FormViewRow)

初始化指定的 FormViewRow 对象。Initializes the specified FormViewRow object.

InsertItem(Boolean)

将当前记录插入到数据源中。Inserts the current record in the data source.

IsBindableType(Type)

确定指定的数据类型是否可以绑定到 FormView 控件中的字段。Determines whether the specified data type can be bound to a field in the FormView control.

IsLiteralContent()

确定服务器控件是否只包含文字内容。Determines if the server control holds only literal content.

(继承自 Control)
LoadControlState(Object)

加载需要保持的 FormView 控件属性的状态(即使在 EnableViewState 属性设置为 false 时)。Loads the state of the FormView control properties that need to be persisted, even when the EnableViewState property is set to false.

LoadViewState(Object)

加载以前保存的 FormView 控件的视图状态。Loads the previously saved view state of the FormView control.

MapPathSecure(String)

检索虚拟路径(绝对的或相对的)映射到的物理路径。Retrieves the physical path that a virtual path, either absolute or relative, maps to.

(继承自 Control)
MarkAsDataBound()

将视图状态中的控件状态设置为成功绑定到数据。Sets the state of the control in view state as successfully bound to data.

(继承自 DataBoundControl)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MergeStyle(Style)

将指定样式的所有非空白元素复制到 Web 控件,但不覆盖该控件现有的任何样式元素。Copies any nonblank elements of the specified style to the Web control, but will not overwrite any existing style elements of the control. 此方法主要由控件开发人员使用。This method is used primarily by control developers.

(继承自 WebControl)
ModifiedOuterTableStylePropertyName()

确定与 FormView 控件关联的表特定 CSS 样式规则是否设置为其默认值。Determines whether the table-specific CSS style rules that are associated with the FormView control are set to their default values.

OnBubbleEvent(Object, EventArgs)

处理在控件层次结构中向上传递的事件。Handles an event passed up through the control hierarchy.

OnCreatingModelDataSource(CreatingModelDataSourceEventArgs)

引发 CreatingModelDataSource 事件。Raises the CreatingModelDataSource event.

(继承自 DataBoundControl)
OnDataBinding(EventArgs)

引发 DataBinding 事件。Raises the DataBinding event.

(继承自 Control)
OnDataBound(EventArgs)

引发 DataBound 事件。Raises the DataBound event.

(继承自 BaseDataBoundControl)
OnDataPropertyChanged()

在某一基数据源标识属性更改后,将数据绑定控件重新绑定到其数据。Rebinds the data-bound control to its data after one of the base data source identification properties changes.

(继承自 DataBoundControl)
OnDataSourceViewChanged(Object, EventArgs)

引发 DataSourceViewChanged 事件。Raises the DataSourceViewChanged event.

(继承自 DataBoundControl)
OnInit(EventArgs)

引发 Init 事件。Raises the Init event.

OnItemCommand(FormViewCommandEventArgs)

引发 ItemCommand 事件。Raises the ItemCommand event.

OnItemCreated(EventArgs)

引发 ItemCreated 事件。Raises the ItemCreated event.

OnItemDeleted(FormViewDeletedEventArgs)

引发 ItemDeleted 事件。Raises the ItemDeleted event.

OnItemDeleting(FormViewDeleteEventArgs)

引发 ItemDeleting 事件。Raises the ItemDeleting event.

OnItemInserted(FormViewInsertedEventArgs)

引发 ItemInserted 事件。Raises the ItemInserted event.

OnItemInserting(FormViewInsertEventArgs)

引发 ItemInserting 事件。Raises the ItemInserting event.

OnItemUpdated(FormViewUpdatedEventArgs)

引发 ItemUpdated 事件。Raises the ItemUpdated event.

OnItemUpdating(FormViewUpdateEventArgs)

引发 ItemUpdating 事件。Raises the ItemUpdating event.

OnLoad(EventArgs)

处理 Load 事件。Handles the Load event.

(继承自 DataBoundControl)
OnModeChanged(EventArgs)

引发 ModeChanged 事件。Raises the ModeChanged event.

OnModeChanging(FormViewModeEventArgs)

引发 ModeChanging 事件。Raises the ModeChanging event.

OnPageIndexChanged(EventArgs)

引发 PageIndexChanged 事件。Raises the PageIndexChanged event.

OnPageIndexChanging(FormViewPageEventArgs)

引发 PageIndexChanging 事件。Raises the PageIndexChanging event.

OnPagePreLoad(Object, EventArgs)

在加载数据绑定控件之前设置该控件的初始化状态。Sets the initialized state of the data-bound control before the control is loaded.

(继承自 DataBoundControl)
OnPreRender(EventArgs)

处理 PreRender 事件。Handles the PreRender event.

(继承自 BaseDataBoundControl)
OnUnload(EventArgs)

引发 Unload 事件。Raises the Unload event.

(继承自 Control)
OpenFile(String)

获取用于读取文件的 StreamGets a Stream used to read a file.

(继承自 Control)
PerformDataBinding(IEnumerable)

将指定数据源绑定到 FormView 控件。Binds the specified data source to the FormView control.

PerformSelect()

从关联的数据源中检索数据。Retrieves data from the associated data source.

(继承自 DataBoundControl)
PrepareControlHierarchy()

设置 FormView 控件的控件层次结构。Sets up the control hierarchy of the FormView control.

RaiseBubbleEvent(Object, EventArgs)

将所有事件源及其信息分配给控件的父级。Assigns any sources of the event and its information to the control's parent.

(继承自 Control)
RaisePostBackEvent(String)

FormView 控件回发到服务器时引发此控件的合适的事件。Raises the appropriate events for the FormView control when it posts back to the server.

RemovedControl(Control)

Control 对象的 Controls 集合移除子控件后调用。Called after a child control is removed from the Controls collection of the Control object.

(继承自 Control)
Render(HtmlTextWriter)

在客户端上显示 FormView 控件。Displays the FormView control on the client.

RenderBeginTag(HtmlTextWriter)

将控件的 HTML 开始标记呈现到指定的编写器中。Renders the HTML opening tag of the control to the specified writer. 此方法主要由控件开发人员使用。This method is used primarily by control developers.

(继承自 WebControl)
RenderChildren(HtmlTextWriter)

将服务器控件子级的内容输出到提供的 HtmlTextWriter 对象,此对象编写将在客户端呈现的内容。Outputs the content of a server control's children to a provided HtmlTextWriter object, which writes the content to be rendered on the client.

(继承自 Control)
RenderContents(HtmlTextWriter)

将控件的内容呈现到指定的编写器中。Renders the contents of the control to the specified writer. 此方法主要由控件开发人员使用。This method is used primarily by control developers.

(继承自 WebControl)
RenderControl(HtmlTextWriter)

将服务器控件内容输出到所提供的 HtmlTextWriter 对象,如果启用了跟踪,则还将存储有关该控件的跟踪信息。Outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled.

(继承自 Control)
RenderControl(HtmlTextWriter, ControlAdapter)

使用提供的 HtmlTextWriter 对象将服务器控件内容输出到提供的 ControlAdapter 对象。Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object.

(继承自 Control)
RenderEndTag(HtmlTextWriter)

将控件的 HTML 结束标记呈现到指定的编写器中。Renders the HTML closing tag of the control into the specified writer. 此方法主要由控件开发人员使用。This method is used primarily by control developers.

(继承自 WebControl)
ResolveAdapter()

获取负责呈现指定控件的控件适配器。Gets the control adapter responsible for rendering the specified control.

(继承自 Control)
ResolveClientUrl(String)

获取浏览器可以使用的 URL。Gets a URL that can be used by the browser.

(继承自 Control)
ResolveUrl(String)

将 URL 转换为在请求客户端可用的 URL。Converts a URL into one that is usable on the requesting client.

(继承自 Control)
SaveControlState()

保存需要保持的 FormView 控件属性的状态(即使在 EnableViewState 属性设置为 false 时)。Saves the state of the FormView control properties that need to be persisted, even when the EnableViewState property is set to false.

SaveViewState()

保存 FormView 控件的当前视图状态。Saves the current view state of the FormView control.

SetDesignModeState(IDictionary)

为控件设置设计时数据。Sets design-time data for a control.

(继承自 Control)
SetPageIndex(Int32)

设置 FormView 控件中当前显示页面的索引。Sets the index of the currently displayed page in the FormView control.

SetRenderMethodDelegate(RenderMethod)

分配事件处理程序委托,以将服务器控件及其内容呈现到父控件中。Assigns an event handler delegate to render the server control and its content into its parent control.

(继承自 Control)
SetTraceData(Object, Object)

使用跟踪数据键和跟踪数据值,为呈现数据的设计时追踪设置跟踪数据。Sets trace data for design-time tracing of rendering data, using the trace data key and the trace data value.

(继承自 Control)
SetTraceData(Object, Object, Object)

使用跟踪对象、跟踪数据键和跟踪数据值,为呈现数据的设计时追踪设置跟踪数据。Sets trace data for design-time tracing of rendering data, using the traced object, the trace data key, and the trace data value.

(继承自 Control)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
TrackViewState()

标记开始跟踪并将视图状态更改保存到 FormView 控件的起始点。Marks the starting point at which to begin tracking and saving view-state changes to the FormView control.

UpdateItem(Boolean)

更新数据源中的当前记录。Updates the current record in the data source.

ValidateDataSource(Object)

验证数据绑定控件绑定到的对象是否可以和该控件一同使用。Verifies that the object a data-bound control binds to is one it can work with.

(继承自 DataBoundControl)

事件

CallingDataMethods

在数据方法正被调用时发生。Occurs when data methods are being called.

(继承自 DataBoundControl)
CreatingModelDataSource

ModelDataSource 对象正被创建时发生。Occurs when the ModelDataSource object is being created.

(继承自 DataBoundControl)
DataBinding

当服务器控件绑定到数据源时发生。Occurs when the server control binds to a data source.

(继承自 Control)
DataBound

在服务器控件绑定到数据源后发生。Occurs after the server control binds to a data source.

(继承自 BaseDataBoundControl)
Disposed

当从内存释放服务器控件时发生,这是请求 ASP.NET 页时服务器控件生存期的最后阶段。Occurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested.

(继承自 Control)
Init

当服务器控件初始化时发生;初始化是控件生存期的第一步。Occurs when the server control is initialized, which is the first step in its lifecycle.

(继承自 Control)
ItemCommand

在单击 FormView 控件中的某个按钮时发生。Occurs when a button within a FormView control is clicked.

ItemCreated

FormView 控件中创建了所有行后发生。Occurs after all the rows are created in a FormView control.

ItemDeleted

在单击 FormView 控件中的“删除”按钮时,但在删除操作之后发生。Occurs when a Delete button within a FormView control is clicked, but after the delete operation.

ItemDeleting

在单击 FormView 控件中的“删除”按钮时,但在删除操作之前发生。Occurs when a Delete button within a FormView control is clicked, but before the delete operation.

ItemInserted

在单击 FormView 控件中的“插入”按钮时,但在插入操作之后发生。Occurs when an Insert button within a FormView control is clicked, but after the insert operation.

ItemInserting

在单击 FormView 控件中的“插入”按钮时,但在插入操作之前发生。Occurs when an Insert button within a FormView control is clicked, but before the insert operation.

ItemUpdated

在单击 FormView 控件中的“更新”按钮时,但在更新操作之后发生。Occurs when an Update button within a FormView control is clicked, but after the update operation.

ItemUpdating

在单击 FormView 控件中的“更新”按钮时,但在更新操作之前发生。Occurs when an Update button within a FormView control is clicked, but before the update operation.

Load

当服务器控件加载到 Page 对象中时发生。Occurs when the server control is loaded into the Page object.

(继承自 Control)
ModeChanged

FormView 控件在编辑、插入和只读模式间切换时,但在模式更改之后发生。Occurs when the FormView control switches between edit, insert, and read-only mode, but after the mode has changed.

ModeChanging

FormView 控件在编辑、插入和只读模式间切换时,但在模式更改之前发生。Occurs when the FormView control switches between edit, insert, and read-only mode, but before the mode changes.

PageIndexChanged

PageIndex 属性的值在分页操作后更改时发生。Occurs when the value of the PageIndex property changes after a paging operation.

PageIndexChanging

PageIndex 属性的值在分页操作前更改时发生。Occurs when the value of the PageIndex property changes before a paging operation.

PreRender

在加载 Control 对象之后、呈现之前发生。Occurs after the Control object is loaded but prior to rendering.

(继承自 Control)
Unload

当服务器控件从内存中卸载时发生。Occurs when the server control is unloaded from memory.

(继承自 Control)

显式界面实现

IAttributeAccessor.GetAttribute(String)

获取具有指定名称的 Web 控件的特性。Gets an attribute of the Web control with the specified name.

(继承自 WebControl)
IAttributeAccessor.SetAttribute(String, String)

将 Web 控件的特性设置为指定的名称和值。Sets an attribute of the Web control to the specified name and value.

(继承自 WebControl)
IControlBuilderAccessor.ControlBuilder

有关此成员的说明,请参见 ControlBuilderFor a description of this member, see ControlBuilder.

(继承自 Control)
IControlDesignerAccessor.GetDesignModeState()

有关此成员的说明,请参见 GetDesignModeState()For a description of this member, see GetDesignModeState().

(继承自 Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

有关此成员的说明,请参见 SetDesignModeState(IDictionary)For a description of this member, see SetDesignModeState(IDictionary).

(继承自 Control)
IControlDesignerAccessor.SetOwnerControl(Control)

有关此成员的说明,请参见 SetOwnerControl(Control)For a description of this member, see SetOwnerControl(Control).

(继承自 Control)
IControlDesignerAccessor.UserData

有关此成员的说明,请参见 UserDataFor a description of this member, see UserData.

(继承自 Control)
IDataBindingsAccessor.DataBindings

有关此成员的说明,请参见 DataBindingsFor a description of this member, see DataBindings.

(继承自 Control)
IDataBindingsAccessor.HasDataBindings

有关此成员的说明,请参见 HasDataBindingsFor a description of this member, see HasDataBindings.

(继承自 Control)
IDataBoundControl.DataKeyNames

获取或设置一个数组,该数组包含显示在 FormView 控件中的项的主键字段的名称。Gets or sets an array that contains the names of the primary-key fields of the items that are displayed in the FormView control.

IDataBoundControl.DataMember

当数据源包含多个数据项列表时,获取或设置 FormView 控件绑定到的数据项列表的名称。Gets or sets the name of the list of data items that the FormView control binds to when the data source contains more than one list of data items.

IDataBoundControl.DataSource

获取或设置包含 FormView 控件所检索到的数据列表的对象。Gets or sets the object that contains the list of data that the FormView control retrieves.

IDataBoundControl.DataSourceID

获取或设置数据源控件的 ID,该数据源控件包含 FormView 控件所检索到的数据项列表。Gets or sets the ID of the data source control that contains the list of data items that the FormView control retrieves.

IDataBoundControl.DataSourceObject

获取数据源对象,该数据源对象包含 FormView 控件所检索到的数据项列表。Gets the data source object that contains the list of data items that the FormView control retrieves.

IDataBoundItemControl.DataKey

获取对象,该对象表示 FormView 控件中行的数据键值。Gets the object that represents the data-key value of the row in the FormView control.

IDataBoundItemControl.Mode

获取 FormView 控件的当前模式。Gets the current mode of the FormView control.

IDataItemContainer.DataItemIndex

有关此成员的说明,请参见 DataItemIndexFor a description of this member, see DataItemIndex.

IDataItemContainer.DisplayIndex

有关此成员的说明,请参见 DisplayIndexFor a description of this member, see DisplayIndex.

IExpressionsAccessor.Expressions

有关此成员的说明,请参见 ExpressionsFor a description of this member, see Expressions.

(继承自 Control)
IExpressionsAccessor.HasExpressions

有关此成员的说明,请参见 HasExpressionsFor a description of this member, see HasExpressions.

(继承自 Control)
IParserAccessor.AddParsedSubObject(Object)

有关此成员的说明,请参见 AddParsedSubObject(Object)For a description of this member, see AddParsedSubObject(Object).

(继承自 Control)
IPostBackContainer.GetPostBackOptions(IButtonControl)

确定 FormView 控件的回发事件选项。Determines the postback event options for the FormView control.

IPostBackEventHandler.RaisePostBackEvent(String)

FormView 控件回发到服务器时引发此控件的事件。Raises events for the FormView control when it posts back to the server.

扩展方法

EnablePersistedSelection(BaseDataBoundControl)

使选定内容能够保留在支持选择和分页的数据控件中。Enables selection to be persisted in data controls that support selection and paging.

FindDataSourceControl(Control)

返回与指定控件的数据控件关联的数据源。Returns the data source that is associated with the data control for the specified control.

FindFieldTemplate(Control, String)

返回指定控件的命名容器中指定列的字段模板。Returns the field template for the specified column in the specified control's naming container.

FindMetaTable(Control)

返回包含数据控件的元表对象。Returns the metatable object for the containing data control.

GetDefaultValues(INamingContainer)

为指定数据控件获取默认值的集合。Gets the collection of the default values for the specified data control.

GetMetaTable(INamingContainer)

为指定数据控件获取表元数据。Gets the table metadata for the specified data control.

SetMetaTable(INamingContainer, MetaTable)

为指定数据控件设置表元数据。Sets the table metadata for the specified data control.

SetMetaTable(INamingContainer, MetaTable, IDictionary<String,Object>)

为指定数据控件设置表元数据和默认值映射。Sets the table metadata and default value mapping for the specified data control.

SetMetaTable(INamingContainer, MetaTable, Object)

为指定数据控件设置表元数据和默认值映射。Sets the table metadata and default value mapping for the specified data control.

TryGetMetaTable(INamingContainer, MetaTable)

确定表元数据是否可用。Determines whether table metadata is available.

EnableDynamicData(INamingContainer, Type)

为指定数据控件启用动态数据行为。Enables Dynamic Data behavior for the specified data control.

EnableDynamicData(INamingContainer, Type, IDictionary<String,Object>)

为指定数据控件启用动态数据行为。Enables Dynamic Data behavior for the specified data control.

EnableDynamicData(INamingContainer, Type, Object)

为指定数据控件启用动态数据行为。Enables Dynamic Data behavior for the specified data control.

适用于

另请参阅