FormView 类

定义

使用用户定义的模板显示数据源中单个记录的值。 FormView 控件可用于编辑、删除和插入记录。

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

示例

下面的示例演示如何使用 FormView 控件显示 控件 SqlDataSource 中的值。


<%@ 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") %> <%# 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") %> <%# 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 控件编辑现有记录。

重要

此示例中的 控件有一个文本框,该文本框接受用户输入,这是一个潜在的安全威胁。 默认情况下,ASP.NET 网页验证用户输入是否不包含脚本或 HTML 元素。 有关详细信息,请参阅脚本侵入概述


<%@ 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">
                    
              </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">
                    
              </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">
                    
              </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">
                    
              </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 控件插入新记录。

重要

此示例中的 控件有一个文本框,该文本框接受用户输入,这是一个潜在的安全威胁。 默认情况下,ASP.NET 网页验证用户输入是否不包含脚本或 HTML 元素。 有关详细信息,请参阅脚本侵入概述


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

注解

本主题内容:

介绍

控件 FormView 用于显示数据源中的单个记录。 它类似于 DetailsView 控件,只不过它显示用户定义的模板而不是行字段。 创建自己的模板可以更灵活地控制数据的显示方式。 控件 FormView 支持以下功能:

  • 绑定到数据源控件,例如 SqlDataSourceObjectDataSource

  • 内置插入功能。

  • 内置的更新和删除功能。

  • 内置分页功能。

  • FormView 编程方式访问对象模型,以动态设置属性、处理事件等。

  • 通过用户定义的模板、主题和样式自定义外观。

模板

若要使 FormView 控件显示内容,需要为控件的不同部分创建模板。 大多数模板都是可选的;但是,必须为配置控件的模式创建模板。 例如,支持插入记录的 FormView 控件必须定义插入项模板。 下表列出了可以创建的不同模板。

模板类型 说明
EditItemTemplate 当控件处于编辑模式时 FormView ,定义数据行的内容。 此模板通常包含用户可编辑现有记录的输入控件和命令按钮。
EmptyDataTemplate 定义当控件绑定到不包含任何记录的数据源时 FormView 显示的空数据行的内容。 此模板通常包含用于提醒用户数据源不包含任何记录的内容。
FooterTemplate 定义页脚行的内容。 此模板通常包含希望在页脚行中显示的任何其他内容。 注意: 作为替代方法,只需通过设置 FooterText 属性来指定要显示在页脚行中的文本。
HeaderTemplate 定义标题行的内容。 此模板通常包含要显示在标题行中的其他任何内容。 注意: 作为替代方法,只需通过设置 HeaderText 属性来指定要在标题行中显示的文本。
ItemTemplate 当控件处于只读模式时 FormView ,定义数据行的内容。 此模板通常包含用于显示现有记录值的内容。
InsertItemTemplate 当控件处于插入模式时 FormView ,定义数据行的内容。 此模板通常包含用户可添加新记录的输入控件和命令按钮。
PagerTemplate 定义启用分页功能时显示的页导航行的内容 (AllowPaging 属性设置为 true) 。 此模板通常包含用户可导航到另一条记录的控件。 注意: 控件 FormView 具有内置页导航行用户界面 (UI) 。 仅当要创建自己的自定义寻呼行时,才需要创建寻呼模板。

若要在项模板中显示字段的值,请使用数据绑定表达式。 有关数据绑定表达式的详细信息,请参阅 数据绑定表达式语法

编辑项模板和插入项模板中的输入控件可以使用双向绑定表达式绑定到数据源的字段。 这允许 FormView 控件自动提取用于更新或插入操作的输入控件的值。 双向绑定表达式还允许编辑项模板中的输入控件自动显示原始字段值。 有关双向绑定表达式的详细信息,请参阅 绑定到数据库

绑定到数据

控件 FormView 可以绑定到数据源控件 ((如 SqlDataSourceObjectDataSourceAccessDataSource) )或实现 System.Collections.IEnumerable 接口的任何数据源集合,例如 System.Data.DataViewSystem.Collections.ArrayListSystem.Collections.Generic.List<T>或其他集合类型。 使用以下方法之一将 FormView 控件绑定到相应的数据源类型:

  • 若要绑定到数据源控件,请将 控件的 FormView 属性设置为DataSourceIDID数据源控件的值。 控件 FormView 自动绑定到指定的数据源控件,并可以利用数据源控件的功能来执行插入、更新、删除和分页功能。 这是绑定到数据的首选方法。

  • 若要绑定到实现 接口的System.Collections.IEnumerable数据源,请以编程方式将 FormView 控件的 属性设置为DataSource数据源,然后调用 DataBind 方法。 使用此方法时, FormView 控件不提供内置的插入、更新、删除和分页功能。 需要使用适当的事件来提供此功能。

有关数据绑定的详细信息,请参阅 ASP.NET 数据访问内容映射

备注

此控件可用于显示用户输入,其中可能包括恶意客户端脚本。 在应用程序中显示之前,请检查从客户端发送的任何信息,以获取可执行脚本、SQL 语句或其他代码。 如果可能,强烈建议先对值进行 HTML 编码,然后再显示在此控件中。 ASP.NET 提供了输入请求验证功能,用于阻止用户输入中的脚本和 HTML。 还提供了验证服务器控件来评估用户输入。 有关详细信息,请参阅 验证控件简介

数据操作

控件 FormView 提供了许多内置功能,允许用户更新、删除、插入和翻页控件中的项。 当控件 FormView 绑定到数据源控件时,该 FormView 控件可以利用数据源控件的功能并提供自动更新、删除、插入和分页功能。

备注

控件 FormView 可以支持对其他类型的数据源执行更新、删除、插入和分页操作;但是,必须为这些操作提供相应的事件处理程序和 实现。

由于 控件 FormView 使用模板,因此它不提供自动生成命令按钮以执行更新、删除或插入操作的方法。 必须在相应的模板中手动包括这些命令按钮。 控件 FormView 可识别属性设置为特定值的某些按钮 CommandName 。 下表列出了控件识别的 FormView 命令按钮。

Button CommandName 值 说明
取消 “取消” 用于更新或插入操作以取消操作并放弃用户输入的值。 然后,控件 FormView 将返回到 属性指定的 DefaultMode 模式。
删除 “Delete” 用于删除操作以从数据源中删除显示的记录。 引发 ItemDeletingItemDeleted 事件。
编辑 “编辑” 用于更新操作以将 FormView 控件置于编辑模式。 为数据行显示 属性中指定的 EditItemTemplate 内容。
插入 “插入” 用于插入操作,以尝试使用用户提供的值在数据源中插入新记录。 引发 ItemInsertingItemInserted 事件。
新建 “新建” 在插入操作中用于将控件置于 FormView 插入模式。 为数据行显示 属性中指定的 InsertItemTemplate 内容。
页面 “Page” 在分页操作中用于表示执行分页的寻呼行中的按钮。 若要指定分页操作,请将按钮的 属性设置为 CommandArgument “Next”、“Prev”、“First”、“Last”或要导航到的页面的索引。 引发 PageIndexChangingPageIndexChanged 事件。 注意: 这种类型的按钮通常仅在寻呼模板中使用。
更新 “Update” 用于更新操作,以尝试使用用户提供的值更新数据源中显示的记录。 引发 ItemUpdatingItemUpdated 事件。

与“删除”按钮 (在) 立即删除显示的记录不同,单击“编辑”或“新建”按钮时, FormView 控件将分别进入编辑或插入模式。 在编辑模式下,将显示当前数据项的属性 EditItemTemplate 中包含的内容。 通常,定义编辑项模板,以便将“编辑”按钮替换为“更新”和“取消”按钮。 适用于字段数据类型 ((如 TextBoxCheckBox 控件) )的输入控件通常还显示字段的值供用户修改。 单击“更新”按钮可更新数据源中的记录,同时单击“取消”按钮将放弃任何更改。

同样,当控件处于插入模式时, InsertItemTemplate 将针对数据项显示 属性中包含的内容。 通常定义插入项模板,以便将“新建”按钮替换为“插入”和“取消”按钮,并显示空的输入控件,以便用户输入新记录的值。 单击“插入”按钮会将记录插入数据源中,同时单击“取消”按钮将放弃任何更改。

控件 FormView 提供分页功能,允许用户导航到数据源中的其他记录。 启用后,页导航行将显示在包含页面导航控件的控件中 FormView 。 若要启用分页,请将 属性 AllowPaging 设置为 true。 可以通过设置 包含在 和 PagerSettings 属性中的 PagerStyle 对象的属性来自定义页客行。 可以使用 属性创建自己的 UI,而不是使用 PagerTemplate 内置的页导航行 UI。

自定义用户界面

可以通过为控件的不同部分设置样式属性来自定义控件的外观 FormView 。 下表列出了不同的样式属性。

Style 属性 说明
EditRowStyle 控件处于编辑模式时数据行的 FormView 样式设置。
EmptyDataRowStyle 当数据源不包含任何记录时,控件中显示的 FormView 空数据行的样式设置。
FooterStyle 控件的页脚行的 FormView 样式设置。
HeaderStyle 控件标题行的 FormView 样式设置。
InsertRowStyle 控件处于插入模式时数据行的 FormView 样式设置。
PagerStyle 启用分页功能时控件中显示的 FormView 页导航行的样式设置。
RowStyle 控件处于只读模式时数据行的 FormView 样式设置。

事件

控件 FormView 提供可对其编程的多个事件。 这样,只要发生事件,就可以运行自定义例程。 下表列出了 控件支持 FormView 的事件。

事件 说明
ItemCommand 在单击 FormView 控件中的某个按钮时发生。 此事件通常用于在控件中单击按钮时执行任务。
ItemCreated 在 控件中创建FormView所有FormViewRow对象后发生。 此事件通常用于在显示记录之前修改记录的值。
ItemDeleted 当“删除”按钮 (按钮的 CommandName 属性设置为“删除”时发生,) 单击控件从数据源中删除记录之后 FormView 。 此事件通常用于检查删除操作的结果。
ItemDeleting 在单击“删除”按钮时,但在控件从数据源中删除记录之前 FormView 发生。 此事件通常用于取消删除操作。
ItemInserted 当“插入”按钮 (其属性设置为“Insert”的按钮 CommandName 时发生,) 单击控件插入记录之后 FormView 。 此事件通常用于检查插入操作的结果。
ItemInserting 在单击“插入”按钮时,但在控件插入记录之前 FormView 发生。 此事件通常用于取消插入操作。
ItemUpdated 当更新按钮 (按钮的 CommandName 属性设置为“更新”时发生,) 单击控件更新行之后 FormView 。 此事件通常用于检查更新操作的结果。
ItemUpdating 在单击“更新”按钮时,但在控件更新记录之前 FormView 发生。 此事件通常用于取消更新操作。
ModeChanged FormView 控件将模式更改为编辑、插入或只读模式 () 后发生。 此事件通常用于在控件更改模式时 FormView 执行任务。
ModeChanging FormView 控件将模式更改为编辑、插入或只读模式 () 之前发生。 此事件通常用于取消模式更改。
PageIndexChanged 在单击某一页导航按钮时,但在 FormView 控件处理分页操作之后发生。 当用户导航到控件中的其他记录后需要执行任务时,通常使用此事件。
PageIndexChanging 在单击某一页导航按钮时,但在 FormView 控件处理分页操作之前发生。 此事件通常用于取消分页操作。

可访问性

有关如何配置此控件以便生成符合辅助功能标准的标记的信息,请参阅 Visual Studio 中的辅助功能和 ASP.NETASP.NET 控件和辅助功能

应用 CSS 样式

控件 FormView 允许你在标记中指定 CSS 样式规则。 如果使用模板自定义控件的外观 FormView ,则可以在模板的标记中指定 CSS 样式。 在这种情况下,不需要额外的外部表。 可以通过将 属性设置为 RenderOuterTablefalse来防止呈现表。

声明性语法

<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"
    RenderOuterTable="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 类的新实例。

属性

AccessKey

获取或设置使您得以快速导航到 Web 服务器控件的访问键。

(继承自 WebControl)
Adapter

获取控件的浏览器特定适配器。

(继承自 Control)
AllowPaging

获取或设置一个值,该值指示是否启用分页功能。

AppRelativeTemplateSourceDirectory

获取或设置包含该控件的 PageUserControl 对象的应用程序相对虚拟目录。

(继承自 Control)
Attributes

获取与控件的特性不对应的任意特性(只用于呈现)的集合。

(继承自 WebControl)
BackColor

获取或设置 Web 服务器控件的背景色。

(继承自 WebControl)
BackImageUrl

获取或设置要在 FormView 控件的背景中显示的图像的 URL。

BindingContainer

获取包含该控件的数据绑定的控件。

(继承自 Control)
BorderColor

获取或设置 Web 控件的边框颜色。

(继承自 WebControl)
BorderStyle

获取或设置 Web 服务器控件的边框样式。

(继承自 WebControl)
BorderWidth

获取或设置 Web 服务器控件的边框宽度。

(继承自 WebControl)
BottomPagerRow

获取 FormViewRow 对象,该对象表示在 FormView 控件底部显示的页导航行。

Caption

获取或设置要在 FormView 控件的 HTML 标题元素中呈现的文本。 提供此属性的目的是使辅助技术设备的用户更易于访问控件。

CaptionAlign

获取或设置 FormView 控件中的 HTML 标题元素的水平或垂直位置。 提供此属性的目的是使辅助技术设备的用户更易于访问控件。

CellPadding

获取或设置单元格的内容和单元格的边框之间的空间量。

CellSpacing

获取或设置单元格间的空间量。

ChildControlsCreated

获取一个值,该值指示是否已创建服务器控件的子控件。

(继承自 Control)
ClientID

获取由 ASP.NET 生成的 HTML 标记的控件 ID。

(继承自 Control)
ClientIDMode

获取或设置用于生成 ClientID 属性值的算法。

(继承自 Control)
ClientIDSeparator

获取一个字符值,该值表示 ClientID 属性中使用的分隔符字符。

(继承自 Control)
Context

为当前 Web 请求获取与服务器控件关联的 HttpContext 对象。

(继承自 Control)
Controls

获取复合数据绑定控件内的子控件的集合。

(继承自 CompositeDataBoundControl)
ControlStyle

获取 Web 服务器控件的样式。 此属性主要由控件开发人员使用。

(继承自 WebControl)
ControlStyleCreated

获取一个值,该值指示是否已为 Style 属性创建了 ControlStyle 对象。 此属性主要由控件开发人员使用。

(继承自 WebControl)
CssClass

获取或设置由 Web 服务器控件在客户端呈现的级联样式表 (CSS) 类。

(继承自 WebControl)
CurrentMode

获取 FormView 控件的当前数据输入模式。

DataItem

获取绑定到 FormView 控件的数据项。

DataItemContainer

如果命名容器实现 IDataItemContainer,则获取对命名容器的引用。

(继承自 Control)
DataItemCount

获取数据源中的数据项的数目。

DataItemIndex

获取从数据源绑定到 FormView 控件的数据项的索引。

DataKey

获取一个 DataKey 对象,该对象表示所显示的记录的主键。

DataKeyNames

获取或设置一个数组,该数组包含数据源的键字段的名称。

DataKeysContainer

如果命名容器实现 IDataKeysControl,则获取对命名容器的引用。

(继承自 Control)
DataMember

当数据源包含多个不同的数据项列表时,获取或设置数据绑定控件绑定到的数据列表的名称。

(继承自 DataBoundControl)
DataSource

获取或设置对象,数据绑定控件从该对象中检索其数据项列表。

(继承自 BaseDataBoundControl)
DataSourceID

获取或设置控件的 ID,数据绑定控件从该控件中检索其数据项列表。

(继承自 DataBoundControl)
DataSourceObject

获取一个对象,该对象实现 IDataSource 接口,以便提供对该对象的数据内容的访问。

(继承自 DataBoundControl)
DefaultMode

获取或设置数据输入模式,FormView 控件在更新、插入或取消操作后返回到该模式。

DeleteMethod

获取或设置控件执行删除操作时调用的页面上的方法的名称。

DeleteMethod

获取或设置为了删除数据要调用的方法的名称。

(继承自 CompositeDataBoundControl)
DesignMode

获取一个值,该值指示是否正在使用设计图面上的一个控件。

(继承自 Control)
EditItemTemplate

获取或设置编辑模式中项的自定义内容。

EditRowStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置 FormView 控件处于编辑模式时数据行的外观。

EmptyDataRowStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置在绑定到 FormView 控件的数据源不包含任何记录时所显示的空数据行的外观。

EmptyDataTemplate

获取或设置在 FormView 控件绑定到不包含任何记录的数据源时所呈现的空数据行的用户定义内容。

EmptyDataText

获取或设置在 FormView 控件绑定到不包含任何记录的数据源时所呈现的空数据行中显示的文本。

Enabled

获取或设置一个值,该值指示是否启用 Web 服务器控件。

(继承自 WebControl)
EnableModelValidation

获取或设置一个值,该值指示验证程序控件是否会处理在插入或更新操作过程中出现的异常。

EnableTheming

获取或设置一个值,该值指示主题是否应用于该控件。

(继承自 WebControl)
EnableViewState

获取或设置一个值,该值指示服务器控件是否向发出请求的客户端保持自己的视图状态以及它所包含的任何子控件的视图状态。

(继承自 Control)
Events

获取控件的事件处理程序委托列表。 此属性为只读。

(继承自 Control)
Font

获取与 Web 服务器控件关联的字体属性。

(继承自 WebControl)
FooterRow

获取表示 FormViewRow 控件中的脚注行的 FormView 对象。

FooterStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置 FormView 控件中的脚注行的外观。

FooterTemplate

获取或设置 FormView 控件中的脚注行的用户定义内容。

FooterText

获取或设置要在 FormView 控件的脚注行中显示的文本。

ForeColor

获取或设置 Web 服务器控件的前景色(通常是文本颜色)。

(继承自 WebControl)
GridLines

获取或设置 FormView 控件的网格线样式。

HasAttributes

获取一个值,该值指示控件是否具有特性集。

(继承自 WebControl)
HasChildViewState

获取一个值,该值指示当前服务器控件的子控件是否具有任何已保存的视图状态设置。

(继承自 Control)
HeaderRow

获取表示 FormViewRow 控件中的标题行的 FormView 对象。

HeaderStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置 FormView 控件中的标题行的外观。

HeaderTemplate

获取或设置 FormView 控件中的标题行的用户定义内容。

HeaderText

获取或设置要在 FormView 控件的标题行中显示的文本。

Height

获取或设置 Web 服务器控件的高度。

(继承自 WebControl)
HorizontalAlign

获取或设置 FormView 控件在页面上的水平对齐方式。

ID

获取或设置分配给服务器控件的编程标识符。

(继承自 Control)
IdSeparator

获取用于分隔控件标识符的字符。

(继承自 Control)
Initialized

获取一个值,该值指示数据绑定控件是否已经初始化。

(继承自 BaseDataBoundControl)
InsertItemTemplate

获取或设置插入模式中项的自定义内容。

InsertMethod

获取或设置控件执行插入操作时调用的页面上的方法的名称。

InsertMethod

获取或设置为了插入数据要调用的方法的名称。

(继承自 CompositeDataBoundControl)
InsertRowStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置在 FormView 控件处于插入模式时该控件中的数据行的外观。

IsBoundUsingDataSourceID

获取指示是否设置 DataSourceID 属性的值。

(继承自 BaseDataBoundControl)
IsChildControlStateCleared

获取一个值,该值指示该控件中包含的控件是否具有控件状态。

(继承自 Control)
IsDataBindingAutomatic

获取一个值,该值指示数据绑定是否自动进行。

(继承自 BaseDataBoundControl)
IsEnabled

获取一个值,该值指示是否启用控件。

(继承自 WebControl)
IsTrackingViewState

获取一个值,用于指示服务器控件是否会将更改保存到其视图状态中。

(继承自 Control)
IsUsingModelBinders

获取一个值,该值指示是否使用模型绑定。

(继承自 CompositeDataBoundControl)
IsViewStateEnabled

获取一个值,该值指示是否为该控件启用了视图状态。

(继承自 Control)
ItemTemplate

获取或设置在 FormView 控件处于只读模式时该控件中的数据行的自定义内容。

ItemType

获取或设置强类型化数据绑定的数据项目类型的名称。

(继承自 DataBoundControl)
LoadViewStateByID

获取一个值,该值指示控件是否通过 ID 而不是索引参与加载其视图状态。

(继承自 Control)
NamingContainer

获取对服务器控件的命名容器的引用,此引用创建唯一的命名空间,以区分具有相同 ID 属性值的服务器控件。

(继承自 Control)
Page

获取对包含服务器控件的 Page 实例的引用。

(继承自 Control)
PageCount

获取显示数据源中的所有记录所需要的总页数。

PageIndex

获取或设置所显示的页的索引。

PagerSettings

获取一个对 PagerSettings 对象的引用,使用该对象可以设置 FormView 控件中的页导航按钮的属性。

PagerStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置 FormView 控件中的页导航行的外观。

PagerTemplate

获取或设置 FormView 控件中页导航行的自定义内容。

Parent

获取对页 UI 层次结构中服务器控件的父控件的引用。

(继承自 Control)
RenderingCompatibility

获取一个值,该值指定呈现的 HTML 将与之兼容的 ASP.NET 版本。

(继承自 Control)
RenderOuterTable

获取或设置一个值,该值指示控件是否将呈现的 HTML 包含在 table 元素中,以便应用内联样式。

RequiresDataBinding

获取或设置一个值,该值指示是否应调用 DataBind() 方法。

(继承自 BaseDataBoundControl)
Row

获取表示 FormViewRow 控件中的数据行的 FormView 对象。

RowStyle

获取一个对 TableItemStyle 对象的引用,使用该对象可以设置在 FormView 控件处于只读模式时该控件中的数据行的外观。

SelectArguments

获取数据绑定控件从数据源控件检索数据时使用的 DataSourceSelectArguments 对象。

(继承自 DataBoundControl)
SelectedValue

获取 FormView 控件中的当前记录的数据键值。

SelectMethod

为了读取数据要调用的方法的名称。

(继承自 DataBoundControl)
Site

获取容器信息,该容器在呈现于设计图面上时承载当前控件。

(继承自 Control)
SkinID

获取或设置要应用于控件的外观。

(继承自 WebControl)
Style

获取将在 Web 服务器控件的外部标记上呈现为样式特性的文本特性的集合。

(继承自 WebControl)
SupportsDisabledAttribute

获取一个值,该值指示在控件的 disabled 属性为 IsEnabled 时,控件是否应将呈现的 HTML 元素的 false 特性设置为 "disabled"。

(继承自 BaseDataBoundControl)
TabIndex

获取或设置 Web 服务器控件的选项卡索引。

(继承自 WebControl)
TagKey

获取 FormView 控件的 HtmlTextWriterTag 值。

TagName

获取控件标记的名称。 此属性主要由控件开发人员使用。

(继承自 WebControl)
TemplateControl

获取或设置对包含该控件的模板的引用。

(继承自 Control)
TemplateSourceDirectory

获取包含当前服务器控件的 PageUserControl 的虚拟目录。

(继承自 Control)
ToolTip

获取或设置当鼠标指针悬停在 Web 服务器控件上时显示的文本。

(继承自 WebControl)
TopPagerRow

获取表示在 FormViewRow 控件顶部显示的页导航行的 FormView 对象。

UniqueID

获取服务器控件的唯一的、以分层形式限定的标识符。

(继承自 Control)
UpdateMethod

获取或设置控件执行更新操作时调用的页面上的方法的名称。

UpdateMethod

获取或设置为了更新数据要调用的方法的名称。

(继承自 CompositeDataBoundControl)
ValidateRequestMode

获取或设置指示控件是否检查来自浏览器的客户端输入是否具有潜在危险值的值。

(继承自 Control)
ViewState

获取状态信息的字典,这些信息使您可以在同一页的多个请求间保存和还原服务器控件的视图状态。

(继承自 Control)
ViewStateIgnoresCase

获取一个值,该值指示 StateBag 对象是否不区分大小写。

(继承自 Control)
ViewStateMode

获取或设置此控件的视图状态模式。

(继承自 Control)
Visible

获取或设置一个值,该值指示服务器控件是否作为 UI 呈现在页上。

(继承自 Control)
Width

获取或设置 Web 服务器控件的宽度。

(继承自 WebControl)

方法

AddAttributesToRender(HtmlTextWriter)

将需要呈现的 HTML 特性和样式添加到指定的 HtmlTextWriterTag 中。 此方法主要由控件开发人员使用。

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

在子控件添加到 Control 对象的 Controls 集合后调用。

(继承自 Control)
AddParsedSubObject(Object)

通知服务器控件,分析了一个元素(XML 或 HTML),并将该元素添加到服务器控件的 ControlCollection 对象中。

(继承自 Control)
ApplyStyle(Style)

将指定样式的所有非空白元素复制到 Web 控件,覆盖控件的所有现有的样式元素。 此方法主要由控件开发人员使用。

(继承自 WebControl)
ApplyStyleSheetSkin(Page)

将页样式表中定义的样式属性应用到控件。

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

开始输出数据的设计时追踪。

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

收集有关服务器控件的信息并将该信息发送到 Trace 属性,在启用页的跟踪功能时将显示该属性。

(继承自 Control)
ChangeMode(FormViewMode)

FormView 控件切换到指定的数据输入模式。

ClearCachedClientID()

将缓存的 ClientID 值设置为 null

(继承自 Control)
ClearChildControlState()

删除服务器控件的子控件的控件状态信息。

(继承自 Control)
ClearChildState()

删除服务器控件的所有子控件的视图状态和控件状态信息。

(继承自 Control)
ClearChildViewState()

删除服务器控件的所有子控件的视图状态信息。

(继承自 Control)
ClearEffectiveClientIDMode()

将当前控件实例和任何子控件的 ClientIDMode 属性设置为 Inherit

(继承自 Control)
ConfirmInitState()

设置数据绑定控件的初始化状态。

(继承自 BaseDataBoundControl)
CopyBaseAttributes(WebControl)

Style 对象未封装的属性从指定的 Web 服务器控件复制到从中调用此方法的 Web 服务器控件。 此方法主要由控件开发人员使用。

(继承自 WebControl)
CreateChildControls()

基于存储在视图状态中的值创建用来呈现复合数据绑定控件的控件层次结构。

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

用指定数据源创建用于呈现 FormView 控件的控件层次结构。

CreateControlCollection()

创建一个新 ControlCollection 对象来保存服务器控件的子控件(包括文本控件和服务器控件)。

(继承自 Control)
CreateControlStyle()

创建 FormView 控件的默认表样式对象。

CreateDataSourceSelectArguments()

创建 DataSourceSelectArguments 对象,该对象包含传递到数据源以进行处理的参数。

CreateRow(Int32, DataControlRowType, DataControlRowState)

使用指定项索引、行类型和行状态创建 FormViewRow 对象。

CreateTable()

FormView 控件创建包含表。

DataBind()

将数据源绑定到 FormView 控件。

DataBind(Boolean)

将数据源绑定到调用的服务器控件及其所有子控件,同时可以选择引发 DataBinding 事件。

(继承自 Control)
DataBindChildren()

将数据源绑定到服务器控件的子控件。

(继承自 Control)
DeleteItem()

从数据源中删除 FormView 控件中的当前记录。

Dispose()

使服务器控件得以在从内存中释放之前执行最后的清理操作。

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

结束输出数据的设计时追踪。

(继承自 Control)
EnsureChildControls()

确定服务器控件是否包含子控件。 如果不包含,则创建子控件。

(继承自 Control)
EnsureDataBound()

请确保 FormView 控件在适当时绑定到数据。

EnsureID()

为尚未分配标识符的控件创建标识符。

(继承自 Control)
Equals(Object)

确定指定对象是否等于当前对象。

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

检索在数据行内声明的每个字段的值,并将这些值存储在指定的 IOrderedDictionary 对象中。

FindControl(String)

在当前的命名容器中搜索带指定 id 参数的服务器控件。

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

使用指定的 idpathOffset 参数(该参数有助于搜索)中指定的整数在当前命名容器中搜索服务器控件。 不应重写此版本的 FindControl 方法。

(继承自 Control)
Focus()

为控件设置输入焦点。

(继承自 Control)
GetData()

检索数据绑定控件用于执行数据操作的 DataSourceView 对象。

(继承自 DataBoundControl)
GetDataSource()

检索与数据绑定控件关联的 IDataSource 接口(如果有)。

(继承自 DataBoundControl)
GetDesignModeState()

获取控件的设计时数据。

(继承自 Control)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetRouteUrl(Object)

获取与一组路由参数对应的 URL。

(继承自 Control)
GetRouteUrl(RouteValueDictionary)

获取与一组路由参数对应的 URL。

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

获取与一组路由参数以及某个路由名称对应的 URL。

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

获取与一组路由参数以及某个路由名称对应的 URL。

(继承自 Control)
GetType()

获取当前实例的 Type

(继承自 Object)
GetUniqueIDRelativeTo(Control)

返回指定控件的 UniqueID 属性的前缀部分。

(继承自 Control)
HasControls()

确定服务器控件是否包含任何子控件。

(继承自 Control)
HasEvents()

返回一个值,该值指示是否为控件或任何子控件注册事件。

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

FormView 控件创建页导航行。

InitializeRow(FormViewRow)

初始化指定的 FormViewRow 对象。

InsertItem(Boolean)

将当前记录插入到数据源中。

IsBindableType(Type)

确定指定的数据类型是否可以绑定到 FormView 控件中的字段。

IsLiteralContent()

确定服务器控件是否只包含文字内容。

(继承自 Control)
LoadControlState(Object)

加载需要保持的 FormView 控件属性的状态(即使在 EnableViewState 属性设置为 false 时)。

LoadViewState(Object)

加载以前保存的 FormView 控件的视图状态。

MapPathSecure(String)

检索虚拟路径(绝对的或相对的)映射到的物理路径。

(继承自 Control)
MarkAsDataBound()

将视图状态中的控件状态设置为成功绑定到数据。

(继承自 DataBoundControl)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
MergeStyle(Style)

将指定样式的所有非空白元素复制到 Web 控件,但不覆盖该控件现有的任何样式元素。 此方法主要由控件开发人员使用。

(继承自 WebControl)
ModifiedOuterTableStylePropertyName()

确定与 FormView 控件关联的表特定 CSS 样式规则是否设置为其默认值。

OnBubbleEvent(Object, EventArgs)

处理在控件层次结构中向上传递的事件。

OnCreatingModelDataSource(CreatingModelDataSourceEventArgs)

引发 CreatingModelDataSource 事件。

(继承自 DataBoundControl)
OnDataBinding(EventArgs)

引发 DataBinding 事件。

(继承自 Control)
OnDataBound(EventArgs)

引发 DataBound 事件。

(继承自 BaseDataBoundControl)
OnDataPropertyChanged()

在某一基数据源标识属性更改后,将数据绑定控件重新绑定到其数据。

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

引发 DataSourceViewChanged 事件。

(继承自 DataBoundControl)
OnInit(EventArgs)

引发 Init 事件。

OnItemCommand(FormViewCommandEventArgs)

引发 ItemCommand 事件。

OnItemCreated(EventArgs)

引发 ItemCreated 事件。

OnItemDeleted(FormViewDeletedEventArgs)

引发 ItemDeleted 事件。

OnItemDeleting(FormViewDeleteEventArgs)

引发 ItemDeleting 事件。

OnItemInserted(FormViewInsertedEventArgs)

引发 ItemInserted 事件。

OnItemInserting(FormViewInsertEventArgs)

引发 ItemInserting 事件。

OnItemUpdated(FormViewUpdatedEventArgs)

引发 ItemUpdated 事件。

OnItemUpdating(FormViewUpdateEventArgs)

引发 ItemUpdating 事件。

OnLoad(EventArgs)

处理 Load 事件。

(继承自 DataBoundControl)
OnModeChanged(EventArgs)

引发 ModeChanged 事件。

OnModeChanging(FormViewModeEventArgs)

引发 ModeChanging 事件。

OnPageIndexChanged(EventArgs)

引发 PageIndexChanged 事件。

OnPageIndexChanging(FormViewPageEventArgs)

引发 PageIndexChanging 事件。

OnPagePreLoad(Object, EventArgs)

在加载数据绑定控件之前设置该控件的初始化状态。

(继承自 DataBoundControl)
OnPreRender(EventArgs)

处理 PreRender 事件。

(继承自 BaseDataBoundControl)
OnUnload(EventArgs)

引发 Unload 事件。

(继承自 Control)
OpenFile(String)

获取用于读取文件的 Stream

(继承自 Control)
PerformDataBinding(IEnumerable)

将指定数据源绑定到 FormView 控件。

PerformSelect()

从关联的数据源中检索数据。

(继承自 DataBoundControl)
PrepareControlHierarchy()

设置 FormView 控件的控件层次结构。

RaiseBubbleEvent(Object, EventArgs)

将所有事件源及其信息分配给控件的父级。

(继承自 Control)
RaisePostBackEvent(String)

FormView 控件回发到服务器时引发此控件的合适的事件。

RemovedControl(Control)

Control 对象的 Controls 集合移除子控件后调用。

(继承自 Control)
Render(HtmlTextWriter)

在客户端上显示 FormView 控件。

RenderBeginTag(HtmlTextWriter)

将控件的 HTML 开始标记呈现到指定的编写器中。 此方法主要由控件开发人员使用。

(继承自 WebControl)
RenderChildren(HtmlTextWriter)

将服务器控件子级的内容输出到提供的 HtmlTextWriter 对象,该对象可写入要在客户端上呈现的内容。

(继承自 Control)
RenderContents(HtmlTextWriter)

将控件的内容呈现到指定的编写器中。 此方法主要由控件开发人员使用。

(继承自 WebControl)
RenderControl(HtmlTextWriter)

将服务器控件内容输出到所提供的 HtmlTextWriter 对象,如果启用了跟踪,则还将存储有关该控件的跟踪信息。

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

使用提供的 HtmlTextWriter 对象将服务器控件内容输出到提供的 ControlAdapter 对象。

(继承自 Control)
RenderEndTag(HtmlTextWriter)

将控件的 HTML 结束标记呈现到指定的编写器中。 此方法主要由控件开发人员使用。

(继承自 WebControl)
ResolveAdapter()

获取负责呈现指定控件的控件适配器。

(继承自 Control)
ResolveClientUrl(String)

获取浏览器可以使用的 URL。

(继承自 Control)
ResolveUrl(String)

将 URL 转换为在请求客户端可用的 URL。

(继承自 Control)
SaveControlState()

保存需要保持的 FormView 控件属性的状态(即使在 EnableViewState 属性设置为 false 时)。

SaveViewState()

保存 FormView 控件的当前视图状态。

SetDesignModeState(IDictionary)

为控件设置设计时数据。

(继承自 Control)
SetPageIndex(Int32)

设置 FormView 控件中当前显示页面的索引。

SetRenderMethodDelegate(RenderMethod)

分配事件处理程序委托,以将服务器控件及其内容呈现到父控件中。

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

使用跟踪数据键和跟踪数据值,为呈现数据的设计时追踪设置跟踪数据。

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

使用跟踪对象、跟踪数据键和跟踪数据值,为呈现数据的设计时追踪设置跟踪数据。

(继承自 Control)
ToString()

返回表示当前对象的字符串。

(继承自 Object)
TrackViewState()

标记开始跟踪并将视图状态更改保存到 FormView 控件的起始点。

UpdateItem(Boolean)

更新数据源中的当前记录。

ValidateDataSource(Object)

验证数据绑定控件绑定到的对象是否可以和该控件一同使用。

(继承自 DataBoundControl)

事件

CallingDataMethods

在数据方法正被调用时发生。

(继承自 DataBoundControl)
CreatingModelDataSource

ModelDataSource 对象正被创建时发生。

(继承自 DataBoundControl)
DataBinding

当服务器控件绑定到数据源时发生。

(继承自 Control)
DataBound

在服务器控件绑定到数据源后发生。

(继承自 BaseDataBoundControl)
Disposed

当从内存释放服务器控件时发生,这是请求 ASP.NET 页时服务器控件生存期的最后阶段。

(继承自 Control)
Init

当服务器控件初始化时发生;初始化是控件生存期的第一步。

(继承自 Control)
ItemCommand

在单击 FormView 控件中的某个按钮时发生。

ItemCreated

FormView 控件中创建了所有行后发生。

ItemDeleted

在单击 FormView 控件中的“删除”按钮时,但在删除操作之后发生。

ItemDeleting

在单击 FormView 控件中的“删除”按钮时,但在删除操作之前发生。

ItemInserted

在单击 FormView 控件中的“插入”按钮时,但在插入操作之后发生。

ItemInserting

在单击 FormView 控件中的“插入”按钮时,但在插入操作之前发生。

ItemUpdated

在单击 FormView 控件中的“更新”按钮时,但在更新操作之后发生。

ItemUpdating

在单击 FormView 控件中的“更新”按钮时,但在更新操作之前发生。

Load

当服务器控件加载到 Page 对象中时发生。

(继承自 Control)
ModeChanged

FormView 控件在编辑、插入和只读模式间切换时,但在模式更改之后发生。

ModeChanging

FormView 控件在编辑、插入和只读模式间切换时,但在模式更改之前发生。

PageIndexChanged

PageIndex 属性的值在分页操作后更改时发生。

PageIndexChanging

PageIndex 属性的值在分页操作前更改时发生。

PreRender

在加载 Control 对象之后、呈现之前发生。

(继承自 Control)
Unload

当服务器控件从内存中卸载时发生。

(继承自 Control)

显式接口实现

IAttributeAccessor.GetAttribute(String)

获取具有指定名称的 Web 控件的特性。

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

将 Web 控件的特性设置为指定的名称和值。

(继承自 WebControl)
IControlBuilderAccessor.ControlBuilder

有关此成员的说明,请参见 ControlBuilder

(继承自 Control)
IControlDesignerAccessor.GetDesignModeState()

有关此成员的说明,请参见 GetDesignModeState()

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

有关此成员的说明,请参见 SetDesignModeState(IDictionary)

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

有关此成员的说明,请参见 SetOwnerControl(Control)

(继承自 Control)
IControlDesignerAccessor.UserData

有关此成员的说明,请参见 UserData

(继承自 Control)
IDataBindingsAccessor.DataBindings

有关此成员的说明,请参见 DataBindings

(继承自 Control)
IDataBindingsAccessor.HasDataBindings

有关此成员的说明,请参见 HasDataBindings

(继承自 Control)
IDataBoundControl.DataKeyNames

获取或设置一个数组,该数组包含显示在 FormView 控件中的项的主键字段的名称。

IDataBoundControl.DataMember

当数据源包含多个数据项列表时,获取或设置 FormView 控件绑定到的数据项列表的名称。

IDataBoundControl.DataSource

获取或设置包含 FormView 控件所检索到的数据列表的对象。

IDataBoundControl.DataSourceID

获取或设置数据源控件的 ID,该数据源控件包含 FormView 控件所检索到的数据项列表。

IDataBoundControl.DataSourceObject

获取数据源对象,该数据源对象包含 FormView 控件所检索到的数据项列表。

IDataBoundItemControl.DataKey

获取对象,该对象表示 FormView 控件中行的数据键值。

IDataBoundItemControl.Mode

获取 FormView 控件的当前模式。

IDataItemContainer.DataItemIndex

有关此成员的说明,请参见 DataItemIndex

IDataItemContainer.DisplayIndex

有关此成员的说明,请参见 DisplayIndex

IExpressionsAccessor.Expressions

有关此成员的说明,请参见 Expressions

(继承自 Control)
IExpressionsAccessor.HasExpressions

有关此成员的说明,请参见 HasExpressions

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

有关此成员的说明,请参见 AddParsedSubObject(Object)

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

确定 FormView 控件的回发事件选项。

IPostBackEventHandler.RaisePostBackEvent(String)

FormView 控件回发到服务器时引发此控件的事件。

扩展方法

EnablePersistedSelection(BaseDataBoundControl)
已过时.

使选定内容能够保留在支持选择和分页的数据控件中。

FindDataSourceControl(Control)

返回与指定控件的数据控件关联的数据源。

FindFieldTemplate(Control, String)

返回指定控件的命名容器中指定列的字段模板。

FindMetaTable(Control)

返回包含数据控件的元表对象。

GetDefaultValues(INamingContainer)

为指定数据控件获取默认值的集合。

GetMetaTable(INamingContainer)

为指定数据控件获取表元数据。

SetMetaTable(INamingContainer, MetaTable)

为指定数据控件设置表元数据。

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

为指定数据控件设置表元数据和默认值映射。

SetMetaTable(INamingContainer, MetaTable, Object)

为指定数据控件设置表元数据和默认值映射。

TryGetMetaTable(INamingContainer, MetaTable)

确定表元数据是否可用。

EnableDynamicData(INamingContainer, Type)

为指定数据控件启用动态数据行为。

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

为指定数据控件启用动态数据行为。

EnableDynamicData(INamingContainer, Type, Object)

为指定数据控件启用动态数据行为。

适用于

另请参阅