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 Web 網頁會驗證使用者輸入未包含指令碼或 HTML 項目。 如需詳細資訊,請參閱 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">
                    
              </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 Web 網頁會驗證使用者輸入未包含指令碼或 HTML 項目。 如需詳細資訊,請參閱 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">
                    
              </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 定義屬性設定 true 為) 時 AllowPaging ,啟用分頁功能時所顯示頁面巡覽列的內容 (。 此範本通常包含使用者可以巡覽至另一筆記錄的控制項。 注意: 控制項 FormView 具有內建的呼叫器資料列使用者介面, (UI) 。 只有在您想要建立自己的自訂呼叫器資料列時,才需要建立呼叫器範本。

若要在專案範本中顯示欄位的值,請使用資料系結運算式。 如需資料系結運算式的詳細資訊,請參閱 資料系結運算式語法

編輯專案範本和插入專案範本中的輸入控制項可以使用雙向系結運算式,系結至資料來源的欄位。 這可讓 FormView 控制項自動擷取更新或插入作業之輸入控制項的值。 雙向系結運算式也允許編輯專案範本中的輸入控制項自動顯示原始域值。 如需雙向系結運算式的詳細資訊,請參閱 系結至資料庫

系結至資料

控制項 FormView 可以系結至資料來源控制項, (例如 SqlDataSourceObjectDataSourceAccessDataSource) 或任何實作 System.Collections.IEnumerable 介面的資料來源集合,例如 System.Data.DataViewSystem.Collections.ArrayListSystem.Collections.Generic.List<T> 或其他集合類型。 使用下列其中一種方法,將 FormView 控制項系結至適當的資料來源類型:

  • 若要系結至資料來源控制項,請將 DataSourceID 控制項的 FormView 屬性設定為 ID 資料來源控制項的值。 控制項 FormView 會自動系結至指定的資料來源控制項,並可以利用資料來源控制項的功能來執行插入、更新、刪除和分頁功能。 這是系結至資料的慣用方法。

  • 若要系結至實作 介面的 System.Collections.IEnumerable 資料來源,請以程式設計方式將 DataSource 控制項的 FormView 屬性設定為數據源,然後呼叫 DataBind 方法。 使用此方法時, FormView 控制項不會提供內建插入、更新、刪除和分頁功能。 您必須使用適當的事件來提供這項功能。

如需資料系結的詳細資訊,請參閱 ASP.NET 資料存取內容對應

注意

此控制項可用來顯示使用者輸入,其中可能包含惡意用戶端腳本。 檢查從用戶端傳送的任何資訊,以取得可執行腳本、SQL 語句或其他程式碼,再將其顯示在應用程式中。 可能的話,強烈建議先以 HTML 編碼值,再顯示于此控制項中。 ASP.NET 提供輸入要求驗證功能,以封鎖使用者輸入中的腳本和 HTML。 也會提供驗證服務器控制項來評估使用者輸入。 如需詳細資訊,請參閱 驗證控制項簡介

資料作業

控制項 FormView 提供許多內建功能,可讓使用者更新、刪除、插入及逐頁查看控制項中的專案。 當 FormView 控制項系結至資料來源控制項時, FormView 控制項可以利用資料來源控制項的功能,並提供自動更新、刪除、插入和分頁功能。

注意

控制項 FormView 可以針對其他類型的資料來源提供更新、刪除、插入和分頁作業的支援;不過,您必須為這些作業提供適當的事件處理常式。

FormView因為控制項使用範本,所以它不提供自動產生命令按鈕的方式來執行更新、刪除或插入作業。 您必須在適當的範本中手動包含這些命令按鈕。 控制項 FormView 可辨識其 CommandName 屬性設定為特定值的特定按鈕。 下表列出控制項可辨識的 FormView 命令按鈕。

按鈕 CommandName 值 描述
取消 「取消」 用於更新或插入作業以取消作業,以及捨棄使用者輸入的值。 控制項 FormView 接著會回到 屬性所 DefaultMode 指定的模式。
刪除 "Delete" 用於刪除作業,從資料來源中刪除顯示的記錄。 ItemDeleting引發 和 ItemDeleted 事件。
編輯 「編輯」 用於更新作業,讓 FormView 控制項處於編輯模式。 屬性中指定的 EditItemTemplate 內容會針對資料列顯示。
插入 「Insert」 用於插入作業,以嘗試使用使用者所提供的值,在資料來源中插入新記錄。 ItemInserting引發 和 ItemInserted 事件。
新增 「新增」 用於插入作業,以將控制項置於 FormView 插入模式。 屬性中指定的 InsertItemTemplate 內容會針對資料列顯示。
頁面 「Page」 用於分頁作業,以代表執行分頁的呼叫器資料列中的按鈕。 若要指定分頁作業,請將 CommandArgument 按鈕的 屬性設定為 「Next」、「Prev」、「First」、「Last」 或要巡覽之頁面的索引。 PageIndexChanging引發 和 PageIndexChanged 事件。 注意: 這種類型的按鈕通常只會在呼叫器範本中使用。
更新 「Update」 用於更新作業,以使用者所提供的值來嘗試更新資料來源中顯示的記錄。 ItemUpdating引發 和 ItemUpdated 事件。

不同于 [刪除] 按鈕 (會立即刪除所顯示記錄) ,按一下 [編輯] 或 [新增] 按鈕時, 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 屬性設定為 「Delete」 ) 的按鈕時,但在控制項從資料來源中刪除記錄之後 FormView 。 此事件通常用來檢查刪除作業的結果。
ItemDeleting 發生于按一下 [刪除] 按鈕時,但在控制項從資料來源中刪除記錄之前 FormView 。 此事件通常用來取消刪除作業。
ItemInserted 發生于按一下 [插入] 按鈕 (屬性 CommandName 設定為 [插入] ) 的按鈕時,但在控制項插入記錄之後 FormView 。 此事件通常用來檢查插入作業的結果。
ItemInserting 發生于按一下 [插入] 按鈕,但在控制項插入記錄之前 FormView 。 此事件通常用來取消插入作業。
ItemUpdated 發生于按一下 [更新] 按鈕 (屬性 CommandName 設定為 [更新] ) 的按鈕時,但在控制項更新資料列之後 FormView 。 此事件通常用來檢查更新作業的結果。
ItemUpdating 發生于按一下 [更新] 按鈕,但在控制項更新記錄之前 FormView 。 此事件通常用來取消更新作業。
ModeChanged 發生于 FormView 控制項變更模式之後, (編輯、插入或唯讀模式) 。 此事件通常用來在控制項變更模式時 FormView 執行工作。
ModeChanging 發生于 FormView 控制項變更模式之前, (編輯、插入或唯讀模式) 。 此事件通常用來取消模式變更。
PageIndexChanged 按一下其中一個頁面巡覽區按鈕時發生 (但在 FormView 控制項處理分頁作業之後)。 當您需要在使用者巡覽至 控制項中的不同記錄之後執行工作時,通常會使用此事件。
PageIndexChanging 發生於按一下其中一個頁面巡覽區按鈕時,但是在 FormView 控制項處理分頁作業之前。 此事件通常用來取消分頁作業。

Accessibility

如需如何設定此控制項以產生符合協助工具標準的標記的相關資訊,請參閱 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

取得或設定便捷鍵 (Access Key),可讓您快速巡覽至 Web 伺服器控制項。

(繼承來源 WebControl)
Adapter

針對控制項取得瀏覽器的特定配置器。

(繼承來源 Control)
AllowPaging

取得或設定值,指出是否啟用分頁功能。

AppRelativeTemplateSourceDirectory

取得或設定包含了此控制項之 PageUserControl 物件的相對應用程式虛擬目錄。

(繼承來源 Control)
Attributes

取得任意屬性 (Attribute) 的集合 (只供呈現),不與控制項上的屬性 (Property) 對應。

(繼承來源 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 標記的控制項識別碼。

(繼承來源 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

取得或設定控制項的識別碼,資料繫結控制項會由此擷取其項目清單。

(繼承來源 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

取得控制項事件處理常式委派 (Delegate) 的清單。 這個屬性是唯讀的。

(繼承來源 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

在網頁控制階層架構中取得伺服器控制項之父控制項的參考。

(繼承來源 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)

使用指定的 id 和有助於搜尋之 pathOffset 參數中所指定的整數,在目前的命名容器中搜尋伺服器控制項。 您不應該覆寫這個版本的 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,此 URL 對應於一組路由參數及一個路由名稱。

(繼承來源 Control)
GetRouteUrl(String, RouteValueDictionary)

取得 URL,此 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)

針對指定的資料控制項啟用動態資料行為。

適用於

另請參閱