DetailsView 類別

定義

從資料表的資料來源顯示單一資料錄的值,其中每個資料列都代表資料錄的欄位。Displays the values of a single record from a data source in a table, where each data row represents a field of the record. DetailsView 控制項可讓您編輯、刪除及插入記錄。The DetailsView control allows you to edit, delete, and insert records.

public ref class DetailsView : System::Web::UI::WebControls::CompositeDataBoundControl, System::Web::UI::ICallbackEventHandler, System::Web::UI::IDataItemContainer, System::Web::UI::IPostBackEventHandler, System::Web::UI::WebControls::ICallbackContainer, System::Web::UI::WebControls::IPostBackContainer
public ref class DetailsView : System::Web::UI::WebControls::CompositeDataBoundControl, System::Web::UI::ICallbackEventHandler, System::Web::UI::IDataItemContainer, System::Web::UI::IPostBackEventHandler, System::Web::UI::WebControls::ICallbackContainer, System::Web::UI::WebControls::IDataBoundItemControl, System::Web::UI::WebControls::IFieldControl, System::Web::UI::WebControls::IPostBackContainer
[System.Web.UI.ControlValueProperty("SelectedValue")]
public class DetailsView : System.Web.UI.WebControls.CompositeDataBoundControl, System.Web.UI.ICallbackEventHandler, System.Web.UI.IDataItemContainer, System.Web.UI.IPostBackEventHandler, System.Web.UI.WebControls.ICallbackContainer, System.Web.UI.WebControls.IPostBackContainer
[System.Web.UI.ControlValueProperty("SelectedValue")]
public class DetailsView : System.Web.UI.WebControls.CompositeDataBoundControl, System.Web.UI.ICallbackEventHandler, System.Web.UI.IDataItemContainer, System.Web.UI.IPostBackEventHandler, System.Web.UI.WebControls.ICallbackContainer, System.Web.UI.WebControls.IDataBoundItemControl, System.Web.UI.WebControls.IFieldControl, System.Web.UI.WebControls.IPostBackContainer
[<System.Web.UI.ControlValueProperty("SelectedValue")>]
type DetailsView = class
    inherit CompositeDataBoundControl
    interface IDataItemContainer
    interface INamingContainer
    interface ICallbackContainer
    interface ICallbackEventHandler
    interface IPostBackEventHandler
    interface IPostBackContainer
[<System.Web.UI.ControlValueProperty("SelectedValue")>]
type DetailsView = class
    inherit CompositeDataBoundControl
    interface IDataItemContainer
    interface INamingContainer
    interface ICallbackContainer
    interface ICallbackEventHandler
    interface IPostBackEventHandler
    interface IPostBackContainer
    interface IDataBoundItemControl
    interface IDataBoundControl
    interface IFieldControl
Public Class DetailsView
Inherits CompositeDataBoundControl
Implements ICallbackContainer, ICallbackEventHandler, IDataItemContainer, IPostBackContainer, IPostBackEventHandler
Public Class DetailsView
Inherits CompositeDataBoundControl
Implements ICallbackContainer, ICallbackEventHandler, IDataBoundItemControl, IDataItemContainer, IFieldControl, IPostBackContainer, IPostBackEventHandler
繼承
屬性
實作

範例

下列程式碼範例示範如何 DetailsView 搭配使用控制項與 GridView 簡單的主版詳細案例的控制項。The following code example demonstrates how to use to use a DetailsView control in combination with a GridView control for a simple master-detail scenario. 它會顯示控制項中所選取專案的詳細資料 GridViewIt displays the details of an item selected in the GridView control.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <table>
        <tr>
          <td>
            <asp:GridView ID="GridView1" runat="server" 
              AutoGenerateColumns="False" DataSourceID="Customers"
              DataKeyNames="CustomerID">
              <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="ContactName" HeaderText="ContactName" />
                <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
              </Columns>
            </asp:GridView>
          </td>
          <td valign="top">
            <asp:DetailsView ID="DetailsView1" runat="server" 
              AutoGenerateRows="True" DataKeyNames="CustomerID"
              DataSourceID="Details" Height="50px" Width="301px">
            </asp:DetailsView>
          </td>
        </tr>
      </table>
      &nbsp;&nbsp;
      <asp:SqlDataSource ID="Details" runat="server" 
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT * FROM [Customers] WHERE ([CustomerID] = @CustomerID)">
        <SelectParameters>
          <asp:ControlParameter ControlID="GridView1" Name="CustomerID" 
            PropertyName="SelectedValue"
            Type="String" />
        </SelectParameters>
      </asp:SqlDataSource>
      <asp:SqlDataSource ID="Customers" runat="server" 
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT [CompanyName], [ContactName], [CustomerID] FROM [Customers]">
      </asp:SqlDataSource>
    </div>
  </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>ASP.NET Example</title>
</head>
<body>
  <form id="form1" runat="server">
    <div>
      <table>
        <tr>
          <td>
            <asp:GridView ID="GridView1" runat="server" 
              AutoGenerateColumns="False" DataSourceID="Customers"
              DataKeyNames="CustomerID">
              <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="ContactName" HeaderText="ContactName" />
                <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
              </Columns>
            </asp:GridView>
          </td>
          <td valign="top">
            <asp:DetailsView ID="DetailsView1" runat="server" 
              AutoGenerateRows="True" DataKeyNames="CustomerID"
              DataSourceID="Details" Height="50px" Width="301px">
            </asp:DetailsView>
          </td>
        </tr>
      </table>
      &nbsp;&nbsp;
      <asp:SqlDataSource ID="Details" runat="server" 
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT * FROM [Customers] WHERE ([CustomerID] = @CustomerID)">
        <SelectParameters>
          <asp:ControlParameter ControlID="GridView1" Name="CustomerID" 
            PropertyName="SelectedValue"
            Type="String" />
        </SelectParameters>
      </asp:SqlDataSource>
      <asp:SqlDataSource ID="Customers" runat="server" 
        ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT [CompanyName], [ContactName], [CustomerID] FROM [Customers]">
      </asp:SqlDataSource>
    </div>
  </form>
</body>
</html>

下列程式碼範例將示範如何使用 DetailsView 控制項來加入、刪除和編輯記錄。The following code example demonstrates how to use the DetailsView control to add, delete, and edit records.


<%@ 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 CustomerDetail_ItemInserted(object sender, 
    DetailsViewInsertedEventArgs e)
  {
    // Refresh the GridView control after a new record is inserted 
    // in the DetailsView control.
    CustomersView.DataBind();
  }

  void CustomerDetail_ItemInserting(object sender, 
    DetailsViewInsertEventArgs e)
  {
    // Iterate though the values entered by the user and HTML encode 
    // the values. This helps prevent malicious values from being 
    // stored in the data source.
    for (int i = 0; i < e.Values.Count; i++)
    {
      if (e.Values[i] != null)
      {
        e.Values[i] = Server.HtmlEncode(e.Values[i].ToString());
      }
    }
  }

  void CustomerDetail_ItemUpdated(object sender, 
    DetailsViewUpdatedEventArgs e)
  {
    // Refresh the GridView control after a new record is updated 
    // in the DetailsView control.
    CustomersView.DataBind();
  }

  void CustomerDetail_ItemUpdating(object sender, 
    DetailsViewUpdateEventArgs e)
  {
    // Iterate though the values entered by the user and HTML encode 
    // the values. This helps prevent malicious values from being 
    // stored in the data source.
    for (int i = 0; i < e.NewValues.Count; i++)
    {
      if (e.NewValues[i] != null)
      {
        e.NewValues[i] = Server.HtmlEncode(e.NewValues[i].ToString());
      }
    }
  }

  void CustomerDetail_ItemDeleted(object sender, 
    DetailsViewDeletedEventArgs e)
  {
    // Refresh the GridView control after a new record is updated 
    // in the DetailsView control.
    CustomersView.DataBind();
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>
      DetailsView Example</title>
</head>
<body>
  <form id="Form1" runat="server">
    <h3>
      DetailsView Example</h3>
    <table cellspacing="10">
      <tr>
        <td>
          <!-- Use a GridView control in combination with      -->
          <!-- a DetailsView control to display master-detail  -->
          <!-- information. When the user selects a store from -->
          <!-- GridView control, the customers//s detailed     -->
          <!-- information is displayed in the DetailsView     -->
          <!-- control.                                        -->
          <asp:GridView ID="CustomersView" DataSourceID="Customers" 
            AutoGenerateColumns="False"
            DataKeyNames="CustomerID" runat="server">
            <HeaderStyle BackColor="Blue" ForeColor="White" />
            <Columns>
              <asp:CommandField ShowSelectButton="True" />
              <asp:BoundField DataField="ContactName" 
                HeaderText="ContactName" />
              <asp:BoundField DataField="CompanyName" 
                HeaderText="CompanyName" />
            </Columns>
          </asp:GridView>
        </td>
        <td valign="top">
          <asp:DetailsView ID="CustomerDetail" 
            DataSourceID="Details" AutoGenerateRows="false"
            AutoGenerateInsertButton="true" 
            AutoGenerateEditButton="true" 
            AutoGenerateDeleteButton="true"
            EmptyDataText="No records." 
            DataKeyNames="CustomerID" GridLines="Both" 
            OnItemInserted="CustomerDetail_ItemInserted"
            OnItemInserting="CustomerDetail_ItemInserting" 
            OnItemUpdated="CustomerDetail_ItemUpdated"
            OnItemUpdating="CustomerDetail_ItemUpdating" 
            OnItemDeleted="CustomerDetail_ItemDeleted"
            runat="server">
            <HeaderStyle BackColor="Navy" ForeColor="White" />
            <RowStyle BackColor="White" />
            <AlternatingRowStyle BackColor="LightGray" />
            <EditRowStyle BackColor="LightCyan" />
            <Fields>
              <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" ReadOnly="True" />
              <asp:BoundField DataField="ContactName" HeaderText="ContactName" />
              <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" />
              <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
              <asp:BoundField DataField="Address" HeaderText="Address" />
              <asp:BoundField DataField="City" HeaderText="City" />
              <asp:BoundField DataField="Region" HeaderText="Region" />
              <asp:BoundField DataField="PostalCode" HeaderText="PostalCode" />
              <asp:BoundField DataField="Country" HeaderText="Country" />
              <asp:BoundField DataField="Phone" HeaderText="Phone" />
              <asp:BoundField DataField="Fax" HeaderText="Fax" />
            </Fields>
          </asp:DetailsView>
        </td>
      </tr>
    </table>
    <!-- This example uses Microsoft SQL Server and connects -->
    <!-- to the Northwind sample database.                   -->
    <!-- It is strongly recommended that each data-bound     -->
    <!-- control uses a separate data source control.        -->
    <asp:SqlDataSource ID="Customers" runat="server" 
      ConnectionString=
        "<%$ ConnectionStrings:NorthwindConnectionString %>"
      SelectCommand="SELECT [CompanyName], [ContactName], [CustomerID] 
        FROM [Customers]">
    </asp:SqlDataSource>
    <!-- Add a filter to the data source control for the     -->
    <!-- DetailsView control to display the details of the   -->
    <!-- store selected in the GridView control.             -->
    <asp:SqlDataSource ID="Details" 
      ConnectionString=
        "<%$ ConnectionStrings:NorthwindConnectionString %>"
      runat="server" 
      SelectCommand="SELECT * FROM [Customers] 
        WHERE ([CustomerID] = @CustomerID)"
      DeleteCommand="DELETE FROM [Customers] 
        WHERE [CustomerID] = @CustomerID"
      InsertCommand="INSERT INTO [Customers] ([CustomerID], 
        [CompanyName], [ContactName], [ContactTitle], [Address], 
        [City], [Region], [PostalCode], [Country], [Phone], [Fax]) 
        VALUES (@CustomerID, @CompanyName, @ContactName, @ContactTitle, 
        @Address, @City, @Region, @PostalCode, @Country, @Phone, @Fax)"
      UpdateCommand="UPDATE [Customers] SET [CompanyName] = @CompanyName, 
        [ContactName] = @ContactName, [ContactTitle] = @ContactTitle, 
        [Address] = @Address, [City] = @City, [Region] = @Region, 
        [PostalCode] = @PostalCode, [Country] = @Country, 
        [Phone] = @Phone, [Fax] = @Fax 
        WHERE [CustomerID] = @CustomerID">
      <SelectParameters>
        <asp:ControlParameter ControlID="CustomersView" 
          Name="CustomerID" PropertyName="SelectedValue"
          Type="String" />
      </SelectParameters>
      <DeleteParameters>
        <asp:Parameter Name="CustomerID" Type="String" />
      </DeleteParameters>
      <UpdateParameters>
        <asp:Parameter Name="CompanyName" Type="String" />
        <asp:Parameter Name="ContactName" Type="String" />
        <asp:Parameter Name="ContactTitle" Type="String" />
        <asp:Parameter Name="Address" Type="String" />
        <asp:Parameter Name="City" Type="String" />
        <asp:Parameter Name="Region" Type="String" />
        <asp:Parameter Name="PostalCode" Type="String" />
        <asp:Parameter Name="Country" Type="String" />
        <asp:Parameter Name="Phone" Type="String" />
        <asp:Parameter Name="Fax" Type="String" />
        <asp:Parameter Name="CustomerID" Type="String" />
      </UpdateParameters>
      <InsertParameters>
        <asp:Parameter Name="CustomerID" Type="String" />
        <asp:Parameter Name="CompanyName" Type="String" />
        <asp:Parameter Name="ContactName" Type="String" />
        <asp:Parameter Name="ContactTitle" Type="String" />
        <asp:Parameter Name="Address" Type="String" />
        <asp:Parameter Name="City" Type="String" />
        <asp:Parameter Name="Region" Type="String" />
        <asp:Parameter Name="PostalCode" Type="String" />
        <asp:Parameter Name="Country" Type="String" />
        <asp:Parameter Name="Phone" Type="String" />
        <asp:Parameter Name="Fax" Type="String" />
      </InsertParameters>
    </asp:SqlDataSource>
  </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 CustomerDetail_ItemInserted(ByVal sender As Object, _
    ByVal e As DetailsViewInsertedEventArgs)
    ' Refresh the GridView control after a new record is inserted in 
    ' the DetailsView control.
    CustomersView.DataBind()
  End Sub
  
  Sub CustomerDetail_ItemInserting(ByVal sender As Object, _
    ByVal e As DetailsViewInsertEventArgs)
    ' Iterate though the values entered by the user and HTML encode 
    ' the values. This helps prevent malicious values from being 
    ' stored in the data source.
    For i As Integer = 0 To e.Values.Count - 1
      If e.Values(i) IsNot Nothing Then
        e.Values(i) = Server.HtmlEncode(e.Values(i).ToString())
      End If
    Next
  End Sub
  
  Sub CustomerDetail_ItemUpdated(ByVal sender As Object, _
    ByVal e As DetailsViewUpdatedEventArgs)
    ' Refresh the GridView control after a new record is updated 
    ' in the DetailsView control.
    CustomersView.DataBind()
  End Sub
  
  Sub CustomerDetail_ItemUpdating(ByVal sender As Object, _
    ByVal e As DetailsViewUpdateEventArgs)
    ' Iterate though the values entered by the user and HTML encode 
    ' the values. This helps prevent malicious values from being 
    ' stored in the data source.
    For i As Integer = 0 To e.NewValues.Count - 1
      If e.NewValues(i) IsNot Nothing Then
        e.NewValues(i) = Server.HtmlEncode(e.NewValues(i).ToString())
      End If
    Next
  End Sub
  
  Sub CustomerDetail_ItemDeleted(ByVal sender As Object, _
    ByVal e As DetailsViewDeletedEventArgs)
    ' Refresh the GridView control after a new record is updated 
    ' in the DetailsView control.
    CustomersView.DataBind()
  End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>DetailsView Example</title>
</head>
<body>
  <form id="Form1" runat="server">
    <h3>DetailsView Example</h3>
    <table cellspacing="10">
      <tr>
        <td>
          <!-- Use a GridView control in combination with      -->
          <!-- a DetailsView control to display master-detail  -->
          <!-- information. When the user selects a store from -->
          <!-- GridView control, the customers's detailed      -->
          <!-- information is displayed in the DetailsView     -->
          <!-- control.                                        -->
          <asp:GridView ID="CustomersView" DataSourceID="Customers" 
            AutoGenerateColumns="False"
            DataKeyNames="CustomerID" runat="server">
            <HeaderStyle BackColor="Blue" ForeColor="White" />
            <Columns>
              <asp:CommandField ShowSelectButton="True" />
              <asp:BoundField DataField="ContactName" 
                HeaderText="ContactName" />
              <asp:BoundField DataField="CompanyName" 
                HeaderText="CompanyName" />
            </Columns>
          </asp:GridView>
        </td>
        <td valign="top">
          <asp:DetailsView ID="CustomerDetail" DataSourceID="Details" 
            AutoGenerateRows="false"
            AutoGenerateInsertButton="true" 
            AutoGenerateEditButton="true" 
            AutoGenerateDeleteButton="true"
            EmptyDataText="No records." 
            DataKeyNames="CustomerID" GridLines="Both" 
            OnItemInserted="CustomerDetail_ItemInserted"
            OnItemInserting="CustomerDetail_ItemInserting" 
            OnItemUpdated="CustomerDetail_ItemUpdated"
            OnItemUpdating="CustomerDetail_ItemUpdating" 
            OnItemDeleted="CustomerDetail_ItemDeleted"
            runat="server">
            <HeaderStyle BackColor="Navy" ForeColor="White" />
            <RowStyle BackColor="White" />
            <AlternatingRowStyle BackColor="LightGray" />
            <EditRowStyle BackColor="LightCyan" />
            <Fields>
              <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" 
                ReadOnly="True" />
              <asp:BoundField DataField="ContactName" HeaderText="ContactName" />
              <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" />
              <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
              <asp:BoundField DataField="Address" HeaderText="Address" />
              <asp:BoundField DataField="City" HeaderText="City" />
              <asp:BoundField DataField="Region" HeaderText="Region" />
              <asp:BoundField DataField="PostalCode" HeaderText="PostalCode" />
              <asp:BoundField DataField="Country" HeaderText="Country" />
              <asp:BoundField DataField="Phone" HeaderText="Phone" />
              <asp:BoundField DataField="Fax" HeaderText="Fax" />
            </Fields>
          </asp:DetailsView>
        </td>
      </tr>
    </table>
    <!-- This example uses Microsoft SQL Server and connects -->
    <!-- to the Northwind sample database.                   -->
    <!-- It is strongly recommended that each data-bound     -->
    <!-- control uses a separate data source control.        -->
    <asp:SqlDataSource ID="Customers" runat="server" 
      ConnectionString=
        "<%$ ConnectionStrings:NorthwindConnectionString %>"
      SelectCommand="SELECT [CompanyName], [ContactName], [CustomerID] 
        FROM [Customers]">
    </asp:SqlDataSource>
    <!-- Add a filter to the data source control for the     -->
    <!-- DetailsView control to display the details of the   -->
    <!-- store selected in the GridView control.             -->
    <asp:SqlDataSource ID="Details" 
      ConnectionString=
        "<%$ ConnectionStrings:NorthwindConnectionString %>"
      runat="server" 
      SelectCommand="SELECT * FROM [Customers] 
        WHERE ([CustomerID] = @CustomerID)"
      DeleteCommand="DELETE FROM [Customers] 
        WHERE [CustomerID] = @CustomerID"
      InsertCommand="INSERT INTO [Customers] ([CustomerID], 
        [CompanyName], [ContactName], [ContactTitle], [Address], 
        [City], [Region], [PostalCode], [Country], [Phone], [Fax]) 
        VALUES (@CustomerID, @CompanyName, @ContactName, 
        @ContactTitle, @Address, @City, @Region, @PostalCode, 
        @Country, @Phone, @Fax)"
      UpdateCommand="UPDATE [Customers] SET 
        [CompanyName] = @CompanyName, 
        [ContactName] = @ContactName, [ContactTitle] = @ContactTitle, 
        [Address] = @Address, [City] = @City, [Region] = @Region, 
        [PostalCode] = @PostalCode, [Country] = @Country, 
        [Phone] = @Phone, [Fax] = @Fax 
        WHERE [CustomerID] = @CustomerID">
      <SelectParameters>
        <asp:ControlParameter ControlID="CustomersView" 
          Name="CustomerID" PropertyName="SelectedValue"
          Type="String" />
      </SelectParameters>
      <DeleteParameters>
        <asp:Parameter Name="CustomerID" Type="String" />
      </DeleteParameters>
      <UpdateParameters>
        <asp:Parameter Name="CompanyName" Type="String" />
        <asp:Parameter Name="ContactName" Type="String" />
        <asp:Parameter Name="ContactTitle" Type="String" />
        <asp:Parameter Name="Address" Type="String" />
        <asp:Parameter Name="City" Type="String" />
        <asp:Parameter Name="Region" Type="String" />
        <asp:Parameter Name="PostalCode" Type="String" />
        <asp:Parameter Name="Country" Type="String" />
        <asp:Parameter Name="Phone" Type="String" />
        <asp:Parameter Name="Fax" Type="String" />
        <asp:Parameter Name="CustomerID" Type="String" />
      </UpdateParameters>
      <InsertParameters>
        <asp:Parameter Name="CustomerID" Type="String" />
        <asp:Parameter Name="CompanyName" Type="String" />
        <asp:Parameter Name="ContactName" Type="String" />
        <asp:Parameter Name="ContactTitle" Type="String" />
        <asp:Parameter Name="Address" Type="String" />
        <asp:Parameter Name="City" Type="String" />
        <asp:Parameter Name="Region" Type="String" />
        <asp:Parameter Name="PostalCode" Type="String" />
        <asp:Parameter Name="Country" Type="String" />
        <asp:Parameter Name="Phone" Type="String" />
        <asp:Parameter Name="Fax" Type="String" />
      </InsertParameters>
    </asp:SqlDataSource>
  </form>
</body>
</html>

下列程式碼範例示範如何以宣告方式將資料欄欄位加入 DetailsView 控制項。The following code example demonstrates how to declaratively add row fields to the DetailsView control.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
  <form id="Form1" runat="server">
    <table cellspacing="10">
      <tr>
        <td>
          <!-- Use a GridView control in combination with      -->
          <!-- a DetailsView control to display master-detail  -->
          <!-- information. When the user selects a store from -->
          <!-- GridView control, the store's detailed          -->
          <!-- information is displayed in the DetailsView     -->
          <!-- control.                                        -->
          <asp:GridView ID="GridView1" runat="server" 
            DataSourceID="Customers" AutoGenerateColumns="False" 
            DataKeyNames="CustomerID">
            <Columns>
              <asp:CommandField ShowSelectButton="True" />
              <asp:BoundField DataField="ContactName" HeaderText="ContactName" />
              <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
            </Columns>
          </asp:GridView>
        </td>
        <td valign="top">
          <asp:DetailsView ID="DetailsView" runat="server"
            DataSourceID="Details" AutoGenerateRows="false"
            DataKeyNames="CustomerID" >
            <HeaderStyle BackColor="Navy" ForeColor="White" />
            <Fields>
              <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" 
                ReadOnly="True" />
              <asp:BoundField DataField="ContactName" HeaderText="ContactName" />
              <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" />
              <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
              <asp:BoundField DataField="City" HeaderText="City" />
              <asp:BoundField DataField="Region" HeaderText="Region" />
              <asp:BoundField DataField="PostalCode" HeaderText="PostalCode" />
              <asp:BoundField DataField="Country" HeaderText="Country" />
            </Fields>
          </asp:DetailsView>
        </td>
      </tr>
    </table>
    <!-- This example uses Microsoft SQL Server and connects -->
    <!-- to the Northwind sample database.                        -->
    <!-- It is strongly recommended that each data-bound     -->
    <!-- control uses a separate data source control.        -->
    <asp:SqlDataSource ID="Customers" runat="server" 
      ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
      SelectCommand="SELECT [CompanyName], [ContactName], [CustomerID] FROM [Customers]">
    </asp:SqlDataSource>
    <!-- Add a filter to the data source control for the     -->
    <!-- DetailsView control to display the details of the   -->
    <!-- store selected in the GridView control.             -->
    <asp:SqlDataSource ID="Details" runat="server" 
      ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
      SelectCommand="SELECT * FROM [Customers] WHERE ([CustomerID] = @CustomerID)">
      <SelectParameters>
        <asp:ControlParameter ControlID="GridView1" Name="CustomerID" 
          PropertyName="SelectedValue"
          Type="String" />
      </SelectParameters>
    </asp:SqlDataSource>
  </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>ASP.NET Example</title>
</head>
<body>
  <form id="Form1" runat="server">
    <table cellspacing="10">
      <tr>
        <td>
          <!-- Use a GridView control in combination with      -->
          <!-- a DetailsView control to display master-detail  -->
          <!-- information. When the user selects a store from -->
          <!-- GridView control, the store's detailed          -->
          <!-- information is displayed in the DetailsView     -->
          <!-- control.                                        -->
          <asp:GridView ID="GridView1" runat="server" 
            DataSourceID="Customers" AutoGenerateColumns="False" 
            DataKeyNames="CustomerID">
            <Columns>
              <asp:CommandField ShowSelectButton="True" />
              <asp:BoundField DataField="ContactName" HeaderText="ContactName" />
              <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
            </Columns>
          </asp:GridView>
        </td>
        <td valign="top">
          <asp:DetailsView ID="DetailsView" runat="server"
            DataSourceID="Details" AutoGenerateRows="false"
            DataKeyNames="CustomerID" >
            <HeaderStyle BackColor="Navy" ForeColor="White" />
            <Fields>
              <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" 
                ReadOnly="True" />
              <asp:BoundField DataField="ContactName" HeaderText="ContactName" />
              <asp:BoundField DataField="ContactTitle" HeaderText="ContactTitle" />
              <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
              <asp:BoundField DataField="City" HeaderText="City" />
              <asp:BoundField DataField="Region" HeaderText="Region" />
              <asp:BoundField DataField="PostalCode" HeaderText="PostalCode" />
              <asp:BoundField DataField="Country" HeaderText="Country" />
            </Fields>
          </asp:DetailsView>
        </td>
      </tr>
    </table>
    <!-- This example uses Microsoft SQL Server and connects -->
    <!-- to the Northwind sample database.                        -->
    <!-- It is strongly recommended that each data-bound     -->
    <!-- control uses a separate data source control.        -->
    <asp:SqlDataSource ID="Customers" runat="server" 
      ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
      SelectCommand="SELECT [CompanyName], [ContactName], [CustomerID] FROM [Customers]">
    </asp:SqlDataSource>
    <!-- Add a filter to the data source control for the     -->
    <!-- DetailsView control to display the details of the   -->
    <!-- store selected in the GridView control.             -->
    <asp:SqlDataSource ID="Details" runat="server" 
      ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
      SelectCommand="SELECT * FROM [Customers] WHERE ([CustomerID] = @CustomerID)">
      <SelectParameters>
        <asp:ControlParameter ControlID="GridView1" Name="CustomerID" 
          PropertyName="SelectedValue"
          Type="String" />
      </SelectParameters>
    </asp:SqlDataSource>
  </form>
</body>
</html>

備註

本主題內容:In this topic:

簡介Introduction

DetailsView 控制項可用來顯示資料表中資料來源的單一記錄,其中記錄的每個欄位都會顯示在資料表的資料列中。The DetailsView control is used to display a single record from a data source in a table, where each field of the record is displayed in a row of the table. 它可與 GridView 主版詳細案例的控制項搭配使用。It can be used in combination with a GridView control for master-detail scenarios. DetailsView控制項支援下列功能:The DetailsView control supports the following features:

  • 系結至資料來源控制項,例如 SqlDataSourceBinding to data source controls, such as SqlDataSource.

  • 內建的插入功能。Built-in inserting capabilities.

  • 內建的更新和刪除功能。Built-in updating and deleting capabilities.

  • 內建的分頁功能。Built-in paging capabilities.

  • 以程式設計方式存取 DetailsView 物件模型,以動態方式設定屬性、處理事件等等。Programmatic access to the DetailsView object model to dynamically set properties, handle events, and so on.

  • 透過主題和樣式可自訂的外觀。Customizable appearance through themes and styles.

資料欄欄位Row Fields

控制項中的每個資料列 DetailsView 都是藉由宣告欄位控制項來建立。Each data row in the DetailsView control is created by declaring a field control. 不同的資料欄欄位類型決定控制項中資料列的行為。Different row field types determine the behavior of the rows in the control. 欄位控制項衍生自 DataControlFieldField controls derive from DataControlField. 下表列出可以使用的不同資料欄欄位類型。The following table lists the different row field types that can be used.

資料列欄位類型Column field type 描述Description
BoundField 將資料來源中的欄位值顯示為文字。Displays the value of a field in a data source as text.
ButtonField 在控制項中顯示命令按鈕 DetailsViewDisplays a command button in the DetailsView control. 這可讓您顯示具有自訂按鈕控制項的資料列,例如 [加入] 或 [移除] 按鈕。This allows you to display a row with a custom button control, such as an Add or a Remove button.
CheckBoxField 在控制項中顯示覆選框 DetailsViewDisplays a check box in the DetailsView control. 此資料欄欄位類型通常用來顯示具有布林值的欄位。This row field type is commonly used to display fields with a Boolean value.
CommandField 顯示內建的命令按鈕,以在控制項中執行編輯、插入或刪除作業 DetailsViewDisplays built-in command buttons to perform edit, insert, or delete operations in the DetailsView control.
HyperLinkField 將資料來源中的欄位值顯示為超連結。Displays the value of a field in a data source as a hyperlink. 此資料欄欄位類型可讓您將第二個欄位系結至超連結的 URL。This row field type allows you to bind a second field to the hyperlink's URL.
ImageField 在控制項中顯示影像 DetailsViewDisplays an image in the DetailsView control.
TemplateField 根據指定的範本,顯示控制項中資料列的使用者定義內容 DetailsViewDisplays user-defined content for a row in the DetailsView control according to a specified template. 這個資料欄欄位型別可讓您建立自訂的資料欄欄位。This row field type allows you to create a custom row field.

根據預設, AutoGenerateRows 屬性會設定為 true ,它會針對資料來源中可系結類型的每個欄位,自動產生系結的資料欄欄位物件。By default, the AutoGenerateRows property is set to true, which automatically generates a bound row field object for each field of a bindable type in the data source. 有效的可系結類型為 StringDateTimeDecimalGuid 和一組基本類型。Valid bindable types are String, DateTime, Decimal, Guid, and the set of primitive types. 然後每個欄位都會以文字的形式顯示在資料列中,並依每個欄位出現在資料來源中的順序顯示。Each field is then displayed in a row as text, in the order in which each field appears in the data source.

自動產生資料列可讓您快速輕鬆地顯示記錄中的每個欄位。Automatically generating the rows provides a quick and easy way to display every field in the record. 不過,若要利用 DetailsView 控制項的 advanced 功能,您必須明確宣告要包含在控制項中的資料欄欄位 DetailsViewHowever, to make use of the DetailsView control's advanced capabilities you must explicitly declare the row fields to include in the DetailsView control. 若要宣告資料欄欄位,請先將 AutoGenerateRows 屬性設定為 falseTo declare the row fields, first set the AutoGenerateRows property to false. 接下來,在 <Fields> 控制項的開頭和結束記號之間加入開頭和結束記號 DetailsViewNext, add opening and closing <Fields> tags between the opening and closing tags of the DetailsView control. 最後,列出您想要在開頭和結束記號之間包含的資料欄欄位 <Fields>Finally, list the row fields that you want to include between the opening and closing <Fields> tags. 指定的資料欄欄位會依列出的順序加入至 Fields 集合中。The row fields specified are added to the Fields collection in the order listed. Fields集合可讓您以程式設計方式管理控制項中的資料欄欄位 DetailsViewThe Fields collection allows you to programmatically manage the row fields in the DetailsView control.

注意

自動產生的資料欄欄位不會加入至 Fields 集合中。Automatically generated row fields are not added to the Fields collection.

注意

明確宣告的資料欄欄位可以與自動產生的資料欄欄位一起顯示。Explicitly declared row fields can be displayed in combination with automatically generated row fields. 使用這兩者時,會先轉譯明確宣告的資料欄欄位,後面接著自動產生的資料欄欄位。When both are used, explicitly declared row fields are rendered first, followed by the automatically generated row fields.

系結至資料Binding to Data

DetailsView控制項可以系結至資料來源控制項 (例如 SqlDataSource 控制項或 ObjectDataSource 控制項) 或任何實介面的資料來源集合 System.Collections.IEnumerable ,例如 System.Data.DataViewSystem.Collections.ArrayListSystem.Collections.Generic.List<T> 或其他集合類型。The DetailsView control can be bound to a data source control (such as the SqlDataSource control or ObjectDataSource control) or to any data source collection that implements the System.Collections.IEnumerable interface, such as System.Data.DataView, System.Collections.ArrayList, System.Collections.Generic.List<T>, or other collection types. 您可以使用下列其中一種方法,將控制項系結 DetailsView 至適當的資料來源類型:Use one of the following methods to bind the DetailsView control to the appropriate data source type:

如需資料系結的詳細資訊,請參閱系結 至資料庫For more information on data binding, see Binding to Databases.

安全性Security

此控制項可以用來顯示使用者輸入,其中可能包含惡意的用戶端腳本。This control can be used to display user input, which might include malicious client script. 檢查從用戶端傳送給可執行腳本、SQL 語句或其他程式碼的任何資訊,然後再將它顯示在您的應用程式中。Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. ASP.NET 提供輸入要求驗證功能,以封鎖使用者輸入中的腳本和 HTML。ASP.NET provides an input request validation feature to block script and HTML in user input. 如需詳細資訊,請參閱 Script Exploits Overview (指令碼攻擊概觀)。For more information, see Script Exploits Overview. 也提供驗證服務器控制項來評估使用者輸入。Validation server controls are also provided to assess user input. 如需詳細資訊,請參閱 驗證服務器控制項語法For more information, see Validation Server Control Syntax.

資料作業Data Operations

DetailsView 控制項提供內建功能,可讓使用者更新、刪除、插入及逐頁流覽控制項中的專案。The DetailsView control provides built-in capabilities that allow the user to update, delete, insert, and page through items in the control. 當控制項系結 DetailsView 至資料來源控制項時, DetailsView 控制項可以利用資料來源控制項的功能,並提供自動更新、刪除、插入和分頁功能。When the DetailsView control is bound to a data source control, the DetailsView control can take advantage of the data source control's capabilities and provide automatic updating, deleting, inserting, and paging functionality.

注意

DetailsView控制項可以支援使用其他資料來源類型的 update、delete、insert 和分頁作業; 不過,您必須在適當的事件處理常式中提供這些作業的執行。The DetailsView control can provide support for update, delete, insert, and paging operations with other types of data sources; however, you must provide the implementation for these operations in an appropriate event handler. 如需詳細資訊,請參閱ItemDeletingItemInsertingItemUpdatingFor more information, see ItemDeleting, ItemInserting, and ItemUpdating.

DetailsView控制項可以將 CommandField AutoGenerateEditButtonAutoGenerateDeleteButtonAutoGenerateInsertButton 屬性分別設定為,以自動加入具有 [編輯]、[刪除] 或 [新增] 按鈕的資料欄欄位 trueThe DetailsView control can automatically add a CommandField row field with an Edit, Delete, or New button by setting the AutoGenerateEditButton, AutoGenerateDeleteButton, or AutoGenerateInsertButton properties to true, respectively. 不同于 [刪除] 按鈕 (會立即刪除選取的記錄) ,按一下 [編輯] 或 [新增] 按鈕時, DetailsView 控制項會分別進入編輯或插入模式。Unlike the Delete button (which deletes the selected record immediately), when the Edit or New button is clicked, the DetailsView control goes into edit or insert mode, respectively. 在編輯模式中,[編輯] 按鈕會取代為 [更新] 和 [取消] 按鈕。In edit mode, the Edit button is replaced with an Update and a Cancel button. 適用于欄位資料類型的輸入控制項 (例如 TextBoxCheckBox 控制項) 會顯示,並顯示使用者要修改的域值。Input controls that are appropriate for the field's data type (such as a TextBox or a CheckBox control) are displayed with a field's value for the user to modify. 按一下 [更新] 按鈕會更新資料來源中的記錄,而按一下 [取消] 按鈕則放棄任何變更。Clicking the Update button updates the record in the data source, while clicking the Cancel button abandons any changes. 同樣地,在插入模式中,[新增] 按鈕會取代為 [插入] 和 [取消] 按鈕,而且會顯示空白的輸入控制項,讓使用者輸入新記錄的值。Likewise, in insert mode, the New button is replaced with an Insert and a Cancel button, and empty input controls are displayed for the user to enter the values for the new record.

注意

您也可以手動定義 ButtonFieldCommandField 或資料欄欄位中的 [更新]、[刪除] 和 [插入] 命令按鈕 TemplateFieldYou can also manually define the update, delete, and insert command buttons in a ButtonField, CommandField, or TemplateField row field. 控制項可辨識 DetailsView CommandName 屬性設定為「編輯」、「更新」、「刪除」、「新增」、「插入」或「取消」的按鈕; 不過,您仍然必須自行提供這些功能。The DetailsView control recognizes buttons with the CommandName property set to "Edit", "Update", "Delete", "New", "Insert", or "Cancel"; however, you still must provide the functionality yourself. 如需詳細資訊,請參閱ItemDeletingItemInsertingItemUpdatingFor more information, see ItemDeleting, ItemInserting, and ItemUpdating.

DetailsView控制項提供分頁功能,可讓使用者流覽至資料來源中的其他記錄。The DetailsView control provides a paging feature, which allows the user to navigate to other records in the data source. 啟用時,頁面導覽控制項會顯示在頁面流覽列中。When enabled, page navigation controls are displayed in a pager row. 若要啟用分頁,請將 AllowPaging 屬性設定為 trueTo enable paging, set the AllowPaging property to true. 您可以使用和屬性來自訂頁面導航資料列 PagerStyle PagerSettingsThe pager row can be customized using the PagerStyle and PagerSettings properties.

自訂消費者介面Customizing the User Interface

您可以 DetailsView 為控制項的不同部分設定樣式屬性,以自訂控制項的外觀。You can customize the appearance of the DetailsView control by setting the style properties for different parts of the control. 下表列出您可以設定的樣式屬性。The following table lists the style properties that you can set.

Style 屬性Style property 描述Description
AlternatingRowStyle 控制項中交替資料列的樣式設定 DetailsViewThe style settings for the alternating data rows in the DetailsView control. 當設定此屬性時,資料列會顯示在群組中, RowStyle 並在設定和設定之間交替 AlternatingRowStyleWhen this property is set, the data rows are displayed in bands, alternating between the RowStyle settings and the AlternatingRowStyle settings.
CommandRowStyle 包含內建命令按鈕之資料列的樣式設定。The style settings for the row that contains the built-in command buttons.
EditRowStyle 當控制項處於編輯模式時,資料列的樣式設定 DetailsViewThe style settings for the data rows when the DetailsView control is in edit mode.
EmptyDataRowStyle DetailsView當資料來源未包含任何記錄時,顯示在控制項中之空白資料列的樣式設定。The style settings for the empty data row that are displayed in the DetailsView control when the data source does not contain any records.
FooterStyle 頁尾資料列的樣式設定。The style settings for the footer row.
HeaderStyle 標頭資料列的樣式設定。The style settings for the header row.
InsertRowStyle 當控制項處於插入模式時,資料列的樣式設定 DetailsViewThe style settings for the data rows when the DetailsView control is in insert mode.
PagerStyle 頁面巡覽列的樣式設定。The style settings for the pager row.
RowStyle 控制項中資料列的樣式設定 DetailsViewThe style settings for the data rows in the DetailsView control. AlternatingRowStyle 同時設定屬性時,資料列會顯示在 RowStyle 設定和設定之間交替 AlternatingRowStyleWhen the AlternatingRowStyle property is also set, the data rows are displayed alternating between the RowStyle settings and the AlternatingRowStyle settings.
FieldHeaderStyle 標頭資料行的樣式設定。The style settings for the header column.

事件Events

DetailsView 控制項提供數個可供您進行程式設計的事件。The DetailsView control provides several events that you can program against. 這可讓您在每次發生事件時執行自訂常式。This allows you to run a custom routine whenever an event occurs. 下表列出控制項支援的事件 DetailsViewThe following table lists the events supported by the DetailsView control. DetailsView控制項也會從其基類繼承這些事件: DataBindingDataBoundDisposed 、、、 Init Load PreRenderRenderThe DetailsView control also inherits these events from its base classes: DataBinding, DataBound, Disposed, Init, Load, PreRender, and Render.

事件Event 描述Description
ItemCommand 按一下 DetailsView 控制項中的按鈕時會發生這個事件。Occurs when a button is clicked in the DetailsView control.
ItemCreated 發生 DetailsViewRow 于控制項中的所有物件建立之後 DetailsViewOccurs after all DetailsViewRow objects are created in the DetailsView control. 此事件通常用來在記錄顯示之前修改記錄的值。This event is often used to modify the values of a record before it is displayed.
ItemDeleted 發生于按一下 [刪除] 按鈕時,但在 DetailsView 控制項從資料來源中刪除記錄之後。Occurs when a Delete button is clicked, but after the DetailsView control deletes the record from the data source. 此事件通常用來檢查刪除作業的結果。This event is often used to check the results of the delete operation.
ItemDeleting 發生于按一下 [刪除] 按鈕時,但在 DetailsView 控制項從資料來源中刪除記錄之前。Occurs when a Delete button is clicked, but before the DetailsView control deletes the record from the data source. 此事件通常用來取消刪除作業。This event is often used to cancel the delete operation.
ItemInserted 發生于按一下 [插入] 按鈕時,但在 DetailsView 控制項插入記錄之後。Occurs when an Insert button is clicked, but after the DetailsView control inserts the record. 此事件通常用來檢查插入作業的結果。This event is often used to check the results of the insert operation.
ItemInserting 發生于按一下 [插入] 按鈕時,但在 DetailsView 控制項插入記錄之前。Occurs when an Insert button is clicked, but before the DetailsView control inserts the record. 此事件通常用來取消插入作業。This event is often used to cancel the insert operation.
ItemUpdated 發生于按一下 [更新] 按鈕時,但在 DetailsView 控制項更新資料列之後。Occurs when an Update button is clicked, but after the DetailsView control updates the row. 此事件通常用來檢查更新作業的結果。This event is often used to check the results of the update operation.
ItemUpdating 發生于按一下 [更新] 按鈕時,但在 DetailsView 控制項更新記錄之前。Occurs when an Update button is clicked, but before the DetailsView control updates the record. 此事件通常用來取消更新作業。This event is often used to cancel the update operation.
ModeChanged 發生于 DetailsView 控制項變更模式之後 (編輯、插入或唯讀模式) 。Occurs after the DetailsView control changes modes (edit, insert, or read-only mode). 當控制項變更模式時,通常會使用這個事件來執行工作 DetailsViewThis event is often used to perform a task when the DetailsView control changes modes.
ModeChanging 發生于 DetailsView 控制項變更模式 (編輯、插入或唯讀模式) 之前。Occurs before the DetailsView control changes modes (edit, insert, or read-only mode). 此事件通常用來取消模式變更。This event is often used to cancel a mode change.
PageIndexChanged 按一下其中一個頁面巡覽區按鈕時發生 (但在 DetailsView 控制項處理分頁作業之後)。Occurs when one of the pager buttons is clicked, but after the DetailsView control handles the paging operation. 當您需要在使用者導覽至控制項中的不同記錄之後執行工作時,通常會使用這個事件。This event is commonly used when you need to perform a task after the user navigates to a different record in the control.
PageIndexChanging 發生於按一下其中一個頁面巡覽區按鈕時,但是在 DetailsView 控制項處理分頁作業之前。Occurs when one of the pager buttons is clicked, but before the DetailsView control handles the paging operation. 此事件通常用來取消分頁作業。This event is often used to cancel the paging operation.

協助工具選項Accessibility

如需如何設定此控制項以產生符合協助工具標準的標記的詳細資訊,請參閱 Visual Studio 和 ASP.NET 以及 ASP.NET 控制項和協助工具中的協助工具。For information about how to configure this control so that it generates markup that conforms to accessibility standards, see Accessibility in Visual Studio and ASP.NET and ASP.NET Controls and Accessibility.

宣告式語法Declarative Syntax

<asp:DetailsView
    AccessKey="string"
    AllowPaging="True|False"
    AutoGenerateDeleteButton="True|False"
    AutoGenerateEditButton="True|False"
    AutoGenerateInsertButton="True|False"
    AutoGenerateRows="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"
    EnablePagingCallbacks="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"
    runat="server"
    SkinID="string"
    Style="string"
    TabIndex="integer"
    ToolTip="string"
    Visible="True|False"
    Width="size"
>
        <AlternatingRowStyle />
        <CommandRowStyle />
        <EditRowStyle />
        <EmptyDataRowStyle />
        <EmptyDataTemplate>
            <!-- child controls -->
        </EmptyDataTemplate>
        <FieldHeaderStyle />
        <Fields>
                <asp:BoundField
                    AccessibleHeaderText="string"
                    ApplyFormatInEditMode="True|False"
                    ConvertEmptyStringToNull="True|False"
                    DataField="string"
                    DataFormatString="string"
                    FooterText="string"
                    HeaderImageUrl="uri"
                    HeaderText="string"
                    HtmlEncode="True|False"
                    InsertVisible="True|False"
                    NullDisplayText="string"
                    ReadOnly="True|False"
                    ShowHeader="True|False"
                    SortExpression="string"
                    Visible="True|False"
>
                        <ControlStyle />
                        <FooterStyle />
                        <HeaderStyle />
                        <ItemStyle />
                </asp:BoundField>
                <asp:ButtonField
                    AccessibleHeaderText="string"
                    ButtonType="Button|Image|Link"
                    CausesValidation="True|False"
                    CommandName="string"
                    DataTextField="string"
                    DataTextFormatString="string"
                    FooterText="string"
                    HeaderImageUrl="uri"
                    HeaderText="string"
                    ImageUrl="uri"
                    InsertVisible="True|False"
                    ShowHeader="True|False"
                    SortExpression="string"
                    Text="string"
                    ValidationGroup="string"
                    Visible="True|False"
>
                        <ControlStyle />
                        <FooterStyle />
                        <HeaderStyle />
                        <ItemStyle />
                </asp:ButtonField>
                <asp:CheckBoxField
                    AccessibleHeaderText="string"
                    DataField="string"
                    FooterText="string"
                    HeaderImageUrl="uri"
                    HeaderText="string"
                    InsertVisible="True|False"
                    ReadOnly="True|False"
                    ShowHeader="True|False"
                    SortExpression="string"
                    Text="string"
                    Visible="True|False"
>
                        <ControlStyle />
                        <FooterStyle />
                        <HeaderStyle />
                        <ItemStyle />
                </asp:CheckBoxField>
                <asp:CommandField
                    AccessibleHeaderText="string"
                    ButtonType="Button|Image|Link"
                    CancelImageUrl="uri"
                    CancelText="string"
                    CausesValidation="True|False"
                    DeleteImageUrl="uri"
                    DeleteText="string"
                    EditImageUrl="uri"
                    EditText="string"
                    FooterText="string"
                    HeaderImageUrl="uri"
                    HeaderText="string"
                    InsertImageUrl="uri"
                    InsertText="string"
                    InsertVisible="True|False"
                    NewImageUrl="uri"
                    NewText="string"
                    SelectImageUrl="uri"
                    SelectText="string"
                    ShowCancelButton="True|False"
                    ShowDeleteButton="True|False"
                    ShowEditButton="True|False"
                    ShowHeader="True|False"
                    ShowInsertButton="True|False"
                    ShowSelectButton="True|False"
                    SortExpression="string"
                    UpdateImageUrl="uri"
                    UpdateText="string"
                    ValidationGroup="string"
                    Visible="True|False"
>
                        <ControlStyle />
                        <FooterStyle />
                        <HeaderStyle />
                        <ItemStyle />
                </asp:CommandField>
                <asp:DynamicField
                    AccessibleHeaderText="string"
                    ApplyFormatInEditMode="True|False"
                    ConvertEmptyStringToNull="True|False"
                    DataField="string"
                    DataFormatString="string"
                    FooterText="string"
                    HeaderImageUrl="uri"
                    HeaderText="string"
                    HtmlEncode="True|False"
                    InsertVisible="True|False"
                    NullDisplayText="string"
                    ShowHeader="True|False"
                    UIHint="string"
                    Visible="True|False"
>
                        <ControlStyle />
                        <FooterStyle />
                        <HeaderStyle />
                        <ItemStyle />
                </asp:DynamicField>
                <asp:HyperLinkField
                    AccessibleHeaderText="string"
                    DataNavigateUrlFields="string"
                    DataNavigateUrlFormatString="string"
                    DataTextField="string"
                    DataTextFormatString="string"
                    FooterText="string"
                    HeaderImageUrl="uri"
                    HeaderText="string"
                    InsertVisible="True|False"
                    NavigateUrl="uri"
                    ShowHeader="True|False"
                    SortExpression="string"
                    Target="string|_blank|_parent|_search|_self|_top"
                    Text="string"
                    Visible="True|False"
>
                        <ControlStyle />
                        <FooterStyle />
                        <HeaderStyle />
                        <ItemStyle />
                </asp:HyperLinkField>
                <asp:ImageField
                    AccessibleHeaderText="string"
                    AlternateText="string"
                    ConvertEmptyStringToNull="True|False"
                    DataAlternateTextField="string"
                    DataAlternateTextFormatString="string"
                    DataImageUrlField="string"
                    DataImageUrlFormatString="string"
                    FooterText="string"
                    HeaderImageUrl="uri"
                    HeaderText="string"
                    InsertVisible="True|False"
                    NullDisplayText="string"
                    NullImageUrl="uri"
                    ReadOnly="True|False"
                    ShowHeader="True|False"
                    SortExpression="string"
                    Visible="True|False"
>
                        <ControlStyle />
                        <FooterStyle />
                        <HeaderStyle />
                        <ItemStyle />
                </asp:ImageField>
                <asp:TemplateField
                    AccessibleHeaderText="string"
                    ConvertEmptyStringToNull="True|False"
                    FooterText="string"
                    HeaderImageUrl="uri"
                    HeaderText="string"
                    InsertVisible="True|False"
                    ShowHeader="True|False"
                    SortExpression="string"
                    Visible="True|False"
>
                            <ControlStyle />
                            <FooterStyle />
                            <HeaderStyle />
                            <ItemStyle />
                        <AlternatingItemTemplate>
                            <!-- child controls -->
                        </AlternatingItemTemplate>
                        <EditItemTemplate>
                            <!-- child controls -->
                        </EditItemTemplate>
                        <FooterTemplate>
                            <!-- child controls -->
                        </FooterTemplate>
                        <HeaderTemplate>
                            <!-- child controls -->
                        </HeaderTemplate>
                        <InsertItemTemplate>
                            <!-- child controls -->
                        </InsertItemTemplate>
                        <ItemTemplate>
                            <!-- child controls -->
                        </ItemTemplate>
                </asp:TemplateField>
        </Fields>
        <FooterStyle />
        <FooterTemplate>
            <!-- child controls -->
        </FooterTemplate>
        <HeaderStyle />
        <HeaderTemplate>
            <!-- child controls -->
        </HeaderTemplate>
        <InsertRowStyle />
        <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:DetailsView>

建構函式

DetailsView()

初始化 DetailsView 類別的新執行個體。Initializes a new instance of the DetailsView class.

屬性

AccessKey

取得或設定便捷鍵 (Access Key),可讓您快速巡覽至 Web 伺服器控制項。Gets or sets the access key that allows you to quickly navigate to the Web server control.

(繼承來源 WebControl)
Adapter

針對控制項取得瀏覽器的特定配置器。Gets the browser-specific adapter for the control.

(繼承來源 Control)
AllowPaging

取得或設定值,指出是否啟用分頁功能。Gets or sets a value indicating whether the paging feature is enabled.

AlternatingRowStyle

取得 TableItemStyle 物件的參考,這個物件可讓您設定 DetailsView 控制項中替代資料列的外觀。Gets a reference to the TableItemStyle object that allows you to set the appearance of the alternating data rows in a DetailsView control.

AppRelativeTemplateSourceDirectory

取得或設定包含了此控制項之 PageUserControl 物件的相對應用程式虛擬目錄。Gets or sets the application-relative virtual directory of the Page or UserControl object that contains this control.

(繼承來源 Control)
Attributes

取得任意屬性 (Attribute) 的集合 (只供呈現),不與控制項上的屬性 (Property) 對應。Gets the collection of arbitrary attributes (for rendering only) that do not correspond to properties on the control.

(繼承來源 WebControl)
AutoGenerateDeleteButton

取得或設定值,指出可刪除目前資料錄的內建控制項是否顯示於 DetailsView 控制項中。Gets or sets a value indicating whether the built-in control to delete the current record is displayed in a DetailsView control.

AutoGenerateEditButton

取得或設定值,指出可編輯目前資料錄的內建控制項是否顯示於 DetailsView 控制項中。Gets or sets a value indicating whether the built-in controls to edit the current record are displayed in a DetailsView control.

AutoGenerateInsertButton

取得或設定值,指出可插入新資料錄的內建控制項是否顯示於 DetailsView 控制項中。Gets or sets a value indicating whether the built-in controls to insert a new record are displayed in a DetailsView control.

AutoGenerateRows

取得或設定值,指出資料來源中每個欄位的資料列欄位是否會自動產生並顯示於 DetailsView 控制項中。Gets or sets a value indicating whether row fields for each field in the data source are automatically generated and displayed in a DetailsView control.

BackColor

取得或設定 Web 伺服器控制項的背景色彩。Gets or sets the background color of the Web server control.

(繼承來源 WebControl)
BackImageUrl

取得或設定要顯示於 DetailsView 控制項背景之影像的 URL。Gets or sets the URL to an image to display in the background of a DetailsView control.

BindingContainer

取得包含了此控制項之資料繫結的控制項。Gets the control that contains this control's data binding.

(繼承來源 Control)
BorderColor

取得或設定 Web 控制項的框線色彩。Gets or sets the border color of the Web control.

(繼承來源 WebControl)
BorderStyle

取得或設定 Web 伺服器控制項的框線樣式。Gets or sets the border style of the Web server control.

(繼承來源 WebControl)
BorderWidth

取得或設定 Web 伺服器控制項的框線寬度。Gets or sets the border width of the Web server control.

(繼承來源 WebControl)
BottomPagerRow

取得 DetailsViewRow 物件,其表示 DetailsView 控制項中的底端頁面巡覽列。Gets a DetailsViewRow object that represents the bottom pager row in a DetailsView control.

Caption

取得或設定要在 DetailsView 控制項之 HTML 標題項目中呈現的文字。Gets or sets the text to render in an HTML caption element in a DetailsView control. 這個屬性可讓協助技術裝置的使用者更容易存取控制項。This property is provided to make the control more accessible to users of assistive technology devices.

CaptionAlign

取得或設定 DetailsView 控制項中 HTML 標題項目的水平或垂直位置。Gets or sets the horizontal or vertical position of the HTML caption element in a DetailsView control. 這個屬性可讓協助技術裝置的使用者更容易存取控制項。This property is provided to make the control more accessible to users of assistive technology devices.

CellPadding

取得或設定儲存格內容和其框線之間的間距。Gets or sets the amount of space between the contents of a cell and the cell's border.

CellSpacing

取得或設定儲存格之間的間距。Gets or sets the amount of space between cells.

ChildControlsCreated

取得值,指出是否已經建立伺服器控制項的子控制項。Gets a value that indicates whether the server control's child controls have been created.

(繼承來源 Control)
ClientID

取得 ASP.NET 所產生之 HTML 標記的控制項識別碼。Gets the control ID for HTML markup that is generated by ASP.NET.

(繼承來源 Control)
ClientIDMode

取得或設定用來產生 ClientID 屬性值的演算法。Gets or sets the algorithm that is used to generate the value of the ClientID property.

(繼承來源 Control)
ClientIDSeparator

取得字元值,表示在 ClientID 屬性中所使用的分隔字元。Gets a character value representing the separator character used in the ClientID property.

(繼承來源 Control)
CommandRowStyle

取得 TableItemStyle 物件的參考,這個物件可讓您設定 DetailsView 控制項中命令資料列的外觀。Gets a reference to the TableItemStyle object that allows you to set the appearance of a command row in a DetailsView control.

Context

取得與目前 Web 要求的伺服器控制項關聯的 HttpContext 物件。Gets the HttpContext object associated with the server control for the current Web request.

(繼承來源 Control)
Controls

取得複合資料繫結控制項內之子控制項的集合。Gets a collection of the child controls within the composite data-bound control.

(繼承來源 CompositeDataBoundControl)
ControlStyle

取得 Web 伺服器控制項的樣式。Gets the style of the Web server control. 這個屬性主要由控制項開發人員使用。This property is used primarily by control developers.

(繼承來源 WebControl)
ControlStyleCreated

取得值,指出 Style 物件是否已經為 ControlStyle 屬性建立。Gets a value indicating whether a Style object has been created for the ControlStyle property. 這個屬性主要由控制項開發人員使用。This property is primarily used by control developers.

(繼承來源 WebControl)
CssClass

取得或設定用戶端上 Web 伺服器控制項所呈現的階層式樣式表 (CSS)。Gets or sets the Cascading Style Sheet (CSS) class rendered by the Web server control on the client.

(繼承來源 WebControl)
CurrentMode

取得 DetailsView 控制項目前的資料輸入模式。Gets the current data-entry mode of the DetailsView control.

DataItem

取得繫結至 DetailsView 控制項的資料項目。Gets the data item bound to the DetailsView control.

DataItemContainer

如果命名容器實作 IDataItemContainer,則取得命名容器的參考。Gets a reference to the naming container if the naming container implements IDataItemContainer.

(繼承來源 Control)
DataItemCount

取得基礎資料來源中的項目數目。Gets the number of items in the underlying data source.

DataItemIndex

取得項目的索引,此項目來自基礎資料來源,目前顯示在 DetailsView 控制項中。Gets the index of the item being displayed in a DetailsView control from the underlying data source.

DataKey

取得 DataKey 物件,表示所顯示資料錄的主索引鍵。Gets a DataKey object that represents the primary key of the displayed record.

DataKeyNames

取得或設定陣列,陣列中包含資料來源的索引鍵欄位名稱。Gets or sets an array that contains the names of the key fields for the data source.

DataKeysContainer

如果命名容器實作 IDataKeysControl,則取得命名容器的參考。Gets a reference to the naming container if the naming container implements IDataKeysControl.

(繼承來源 Control)
DataMember

取得或設定資料繫結控制項繫結至的資料清單名稱 (如果資料來源包含多個不同資料項目清單)。Gets or sets the name of the list of data that the data-bound control binds to, in cases where the data source contains more than one distinct list of data items.

(繼承來源 DataBoundControl)
DataSource

取得或設定資料繫結控制項從中擷取其資料項目清單的物件。Gets or sets the object from which the data-bound control retrieves its list of data items.

(繼承來源 BaseDataBoundControl)
DataSourceID

取得或設定控制項的識別碼,資料繫結控制項會由此擷取其項目清單。Gets or sets the ID of the control from which the data-bound control retrieves its list of data items.

(繼承來源 DataBoundControl)
DataSourceObject

取得物件,這個物件會實作可提供物件資料內容之存取權的 IDataSource 介面。Gets an object that implements the IDataSource interface, which provides access to the object's data content.

(繼承來源 DataBoundControl)
DefaultMode

取得或設定 DetailsView 控制項的預設資料輸入模式。Get or sets the default data-entry mode of the DetailsView control.

DeleteMethod

取得或設定在頁面上控制項執行刪除作業時所呼叫的方法名稱。Gets or sets the name of the method on the page that is called when the control performs a delete operation.

DeleteMethod

為了刪除資料,取得或設定要呼叫的方法名稱。Gets or sets the name of the method to call in order to delete data.

(繼承來源 CompositeDataBoundControl)
DesignMode

取得值,指出控制項是否正用於設計介面上。Gets a value indicating whether a control is being used on a design surface.

(繼承來源 Control)
EditRowStyle

取得 TableItemStyle 物件的參考,這個物件可以讓您設定當 DetailsView 控制項處於編輯模式時的資料列外觀。Gets a reference to the TableItemStyle object that allows you to set the appearance of the data rows when a DetailsView control is in edit mode.

EmptyDataRowStyle

取得 TableItemStyle 物件的參考,可以讓您設定當繫結至 DetailsView 控制項的資料來源不含任何資料錄時,顯示之空白資料列的外觀。Gets a reference to the TableItemStyle object that allows you to set the appearance of the empty data row displayed when the data source bound to a DetailsView control does not contain any records.

EmptyDataTemplate

取得或設定空白資料之使用者定義的內容,該資料列呈現於 DetailsView 控制項繫結至不包含任何資料錄的資料來源時。Gets or sets the user-defined content for the empty data row rendered when a DetailsView control is bound to a data source that does not contain any records.

EmptyDataText

取得或設定空白資料列中顯示的文字,該資料列呈現於 DetailsView 控制項繫結至不包含任何資料錄的資料來源時。Gets or sets the text to display in the empty data row rendered when a DetailsView control is bound to a data source that does not contain any records.

Enabled

取得或設定值,指出 Web 伺服器控制項是否啟用。Gets or sets a value indicating whether the Web server control is enabled.

(繼承來源 WebControl)
EnableModelValidation

取得或設定值,這個值指出是否啟用資料模型驗證。Gets or sets a value that indicates whether data-model validation is enabled.

EnablePagingCallbacks

取得或設定值,指出是否在 DetailsView 控制項的分頁作業中使用用戶端回呼函式 (Callback Function)。Gets or sets a value indicating whether client-side callback functions are used for paging operations in the DetailsView control.

EnableTheming

取得或設定值,指出佈景主題是否套用至此控制項。Gets or sets a value indicating whether themes apply to this control.

(繼承來源 WebControl)
EnableViewState

取得或設定值,該值表示伺服器控制項是否對要求的用戶端而言保持其檢視狀態,以及它包含的任何子控制項狀態。Gets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client.

(繼承來源 Control)
Events

取得控制項事件處理常式委派 (Delegate) 的清單。Gets a list of event handler delegates for the control. 這個屬性是唯讀的。This property is read-only.

(繼承來源 Control)
FieldHeaderStyle

取得 TableItemStyle 物件的參考,這個物件可讓您設定 DetailsView 控制項中標頭資料行的外觀。Gets a reference to the TableItemStyle object that allows you to set the appearance of the header column in a DetailsView control.

Fields

取得 DataControlField 物件的集合,表示 DetailsView 控制項中明確宣告的資料列欄位。Gets a collection of DataControlField objects that represent the explicitly declared row fields in a DetailsView control.

Font

取得與 Web 伺服器控制項關聯的字型屬性。Gets the font properties associated with the Web server control.

(繼承來源 WebControl)
FooterRow

取得 DetailsViewRow 物件,其表示 DetailsView 控制項中的頁尾資料列。Gets a DetailsViewRow object that represents the footer row in a DetailsView control.

FooterStyle

取得 TableItemStyle 物件的參考,可以讓您設定 DetailsView 控制項中頁尾資料列的外觀。Gets a reference to the TableItemStyle object that allows you to set the appearance of the footer row in a DetailsView control.

FooterTemplate

取得或設定 DetailsView 控制項中,頁尾資料列的使用者定義內容。Gets or sets the user-defined content for the footer row in a DetailsView control.

FooterText

取得或設定顯示於 DetailsView 控制項頁尾資料列的文字。Gets or sets the text to display in the footer row of a DetailsView control.

ForeColor

取得或設定 Web 伺服器控制項的前景色彩 (通常是文字的色彩)。Gets or sets the foreground color (typically the color of the text) of the Web server control.

(繼承來源 WebControl)
GridLines

取得或設定 DetailsView 控制項的格線樣式。Gets or sets the gridline style for a DetailsView control.

HasAttributes

取得值,指出控制項是否已經設定屬性。Gets a value indicating whether the control has attributes set.

(繼承來源 WebControl)
HasChildViewState

取得值,指出目前伺服器控制項的子控制項是否有任何已儲存的檢視狀態設定。Gets a value indicating whether the current server control's child controls have any saved view-state settings.

(繼承來源 Control)
HeaderRow

取得 DetailsViewRow 物件,表示 DetailsView 控制項中的標頭資料列。Gets a DetailsViewRow object that represents the header row in a DetailsView control.

HeaderStyle

取得 TableItemStyle 物件的參考,可以讓您設定 DetailsView 控制項中頁首資料列的外觀。Gets a reference to the TableItemStyle object that allows you to set the appearance of the header row in a DetailsView control.

HeaderTemplate

取得或設定 DetailsView 控制項中,標頭資料列的使用者定義內容。Gets or sets the user-defined content for the header row in a DetailsView control.

HeaderText

取得或設定顯示於 DetailsView 控制項中頁首資料列的文字。Gets or sets the text to display in the header row of a DetailsView control.

Height

取得或設定 Web 伺服器控制項的高度。Gets or sets the height of the Web server control.

(繼承來源 WebControl)
HorizontalAlign

取得或設定頁面上 DetailsView 控制項的水平對齊。Gets or sets the horizontal alignment of a DetailsView control on the page.

ID

取得或設定指派給伺服器控制項的程式設計識別項。Gets or sets the programmatic identifier assigned to the server control.

(繼承來源 Control)
IdSeparator

取得用來分隔控制項識別項的字元。Gets the character used to separate control identifiers.

(繼承來源 Control)
Initialized

取得值,指出是否已初始化資料繫結控制項。Gets a value indicating whether the data-bound control has been initialized.

(繼承來源 BaseDataBoundControl)
InsertMethod

取得或設定在頁面上控制項執行插入作業時所呼叫的方法名稱。Gets or sets the name of the method on the page that is called when the control performs an insert operation.

InsertMethod

為了插入資料,取得或設定要呼叫的方法名稱。Gets or sets the name of the method to call in order to insert data.

(繼承來源 CompositeDataBoundControl)
InsertRowStyle

取得 TableItemStyle 物件的參考,這個物件可讓您在 DetailsView 控制項處於插入模式時,設定 DetailsView 控制項中資料列的外觀。Gets a reference to the TableItemStyle object that allows you to set the appearance of the data rows in a DetailsView control when the DetailsView control is in insert mode.

IsBoundUsingDataSourceID

取得值,指出是否已設定 DataSourceID 屬性。Gets a value indicating whether the DataSourceID property is set.

(繼承來源 BaseDataBoundControl)
IsChildControlStateCleared

取得值,指出這個控制項中所包含的控制項是否有控制項狀態。Gets a value indicating whether controls contained within this control have control state.

(繼承來源 Control)
IsDataBindingAutomatic

取得值,指出資料繫結是否為自動。Gets a value that indicates whether data binding is automatic.

(繼承來源 BaseDataBoundControl)
IsEnabled

取得值,指出是否啟用控制項。Gets a value indicating whether the control is enabled.

(繼承來源 WebControl)
IsTrackingViewState

取得值,指出伺服器控制項是否正在儲存檢視狀態的變更。Gets a value that indicates whether the server control is saving changes to its view state.

(繼承來源 Control)
IsUsingModelBinders

取得值,指出模型繫結是否正在使用。Gets a value that indicates whether model binding is in use.

(繼承來源 CompositeDataBoundControl)
IsViewStateEnabled

取得值,指出這個控制項是否已啟用檢視狀態。Gets a value indicating whether view state is enabled for this control.

(繼承來源 Control)
ItemType

取得或設定強型別資料繫結的資料項目型別名稱。Gets or sets the name of the data item type for strongly typed data binding.

(繼承來源 DataBoundControl)
LoadViewStateByID

取得值,指出控制項是否依 ID (而不是索引) 參與載入其檢視狀態。Gets a value indicating whether the control participates in loading its view state by ID instead of index.

(繼承來源 Control)
NamingContainer

取得伺服器控制項命名容器的參考,其建立唯一命名空間,在具有相同 ID 屬性值的伺服器控制項之間作區別。Gets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same ID property value.

(繼承來源 Control)
Page

取得含有伺服器控制項的 Page 執行個體的參考。Gets a reference to the Page instance that contains the server control.

(繼承來源 Control)
PageCount

取得資料來源中的資料錄數目。Gets the number of records in the data source.

PageIndex

取得或設定顯示資料錄的索引。Gets or sets the index of the displayed record.

PagerSettings

取得 PagerSettings 物件的參考,可以讓您設定 DetailsView 控制項中頁面巡覽區按鈕的屬性。Gets a reference to the PagerSettings object that allows you to set the properties of the pager buttons in a DetailsView control.

PagerStyle

取得 TableItemStyle 物件的參考,可以讓您設定 DetailsView 控制項中頁面巡覽列的外觀。Gets a reference to the TableItemStyle object that allows you to set the appearance of the pager row in a DetailsView control.

PagerTemplate

取得或設定 DetailsView 控制項中頁面巡覽列的自訂內容。Gets or sets the custom content for the pager row in a DetailsView control.

Parent

在網頁控制階層架構中取得伺服器控制項之父控制項的參考。Gets a reference to the server control's parent control in the page control hierarchy.

(繼承來源 Control)
RenderingCompatibility

取得值,這個值會指定將與呈現 HTML 相容的 ASP.NET 版本。Gets a value that specifies the ASP.NET version that rendered HTML will be compatible with.

(繼承來源 Control)
RequiresDataBinding

取得或設定值,指出是否應該呼叫 DataBind() 方法。Gets or sets a value indicating whether the DataBind() method should be called.

(繼承來源 BaseDataBoundControl)
Rows

取得 DetailsViewRow 物件的集合,其表示 DetailsView 控制項中的資料列。Gets a collection of DetailsViewRow objects that represent the data rows in a DetailsView control.

RowsGenerator

取得或設定物件,這個物件會實作 IAutoFieldGenerator 介面,以便在檢視中自動填入資料列。Gets or sets an object that implements the IAutoFieldGenerator interface in order to automatically populate rows in the view.

RowStyle

取得 TableItemStyle 物件的參考,這個物件可讓您設定 DetailsView 控制項中資料列的外觀。Gets a reference to the TableItemStyle object that allows you to set the appearance of the data rows in a DetailsView control.

SelectArguments

取得 DataSourceSelectArguments 物件,當從資料來源控制項擷取資料時資料繫結控制項會使用它。Gets a DataSourceSelectArguments object that the data-bound control uses when retrieving data from a data source control.

(繼承來源 DataBoundControl)
SelectedValue

取得 DetailsView 控制項中目前資料錄的資料索引鍵值。Gets the data key value of the current record in a DetailsView control.

SelectMethod

為了讀取資料要呼叫的方法的名稱。The name of the method to call in order to read data.

(繼承來源 DataBoundControl)
Site

當呈現在設計介面上時,取得裝載目前控制項之容器的資訊。Gets information about the container that hosts the current control when rendered on a design surface.

(繼承來源 Control)
SkinID

取得或設定要套用至控制項的面板。Gets or sets the skin to apply to the control.

(繼承來源 WebControl)
Style

取得文字屬性的集合,將呈現為 Web 伺服器控制項的外部標記上的樣式屬性。Gets a collection of text attributes that will be rendered as a style attribute on the outer tag of the Web server control.

(繼承來源 WebControl)
SupportsDisabledAttribute

取得值,這個值表示當控制項的 disabled 屬性為 IsEnabled 時,控制項是否應該將呈現之 HTML 項目的 false 屬性設為 "disabled"。Gets a value that indicates whether the control should set the disabled attribute of the rendered HTML element to "disabled" when the control's IsEnabled property is false.

(繼承來源 BaseDataBoundControl)
TabIndex

取得或設定 Web 伺服器控制項的定位索引。Gets or sets the tab index of the Web server control.

(繼承來源 WebControl)
TagKey

取得 DetailsView 控制項的 HtmlTextWriterTag 值。Gets the HtmlTextWriterTag value for the DetailsView control.

TagName

取得控制項標記的名稱。Gets the name of the control tag. 這個屬性主要由控制項開發人員使用。This property is used primarily by control developers.

(繼承來源 WebControl)
TemplateControl

取得或設定包含了此控制項之樣板的參考。Gets or sets a reference to the template that contains this control.

(繼承來源 Control)
TemplateSourceDirectory

取得包含目前伺服器控制項的 PageUserControl 的虛擬目錄。Gets the virtual directory of the Page or UserControl that contains the current server control.

(繼承來源 Control)
ToolTip

取得或設定當滑鼠指標停留在 Web 伺服器控制項時顯示的文字。Gets or sets the text displayed when the mouse pointer hovers over the Web server control.

(繼承來源 WebControl)
TopPagerRow

取得 DetailsViewRow 物件,其表示 DetailsView 控制項中的頂端頁面巡覽列。Gets a DetailsViewRow object that represents the top pager row in a DetailsView control.

UniqueID

取得伺服器控制項唯一的、符合階層架構的識別項。Gets the unique, hierarchically qualified identifier for the server control.

(繼承來源 Control)
UpdateMethod

取得或設定在頁面上控制項執行更新作業時所呼叫的方法名稱。Gets or sets the name of the method on the page that is called when the control performs an update operation.

UpdateMethod

為了更新資料,取得或設定要呼叫的方法名稱。Gets or sets the name of the method to call in order to update data.

(繼承來源 CompositeDataBoundControl)
ValidateRequestMode

取得或設定值,指出控制項是否對來自瀏覽器的用戶端輸入檢查潛在的危險值。Gets or sets a value that indicates whether the control checks client input from the browser for potentially dangerous values.

(繼承來源 Control)
ViewState

取得狀態資訊的字典,允許您在相同網頁的多個要求之間,儲存和還原伺服器控制項的檢視狀態。Gets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page.

(繼承來源 Control)
ViewStateIgnoresCase

取得值,指出 StateBag 物件是否不區分大小寫。Gets a value that indicates whether the StateBag object is case-insensitive.

(繼承來源 Control)
ViewStateMode

取得或設定這個控制項的檢視狀態模式。Gets or sets the view-state mode of this control.

(繼承來源 Control)
Visible

取得或設定值,指出伺服器控制項是否會轉譯為頁面上的 UI。Gets or sets a value that indicates whether a server control is rendered as UI on the page.

(繼承來源 Control)
Width

取得或設定 Web 伺服器控制項的寬度。Gets or sets the width of the Web server control.

(繼承來源 WebControl)

方法

AddAttributesToRender(HtmlTextWriter)

將需要呈現的 HTML 屬性和樣式加入至指定的 HtmlTextWriterTag 中。Adds HTML attributes and styles that need to be rendered to the specified HtmlTextWriterTag. 這個方法主要由控制項開發人員使用。This method is used primarily by control developers.

(繼承來源 WebControl)
AddedControl(Control, Int32)

在子控制項加入 Control 物件的 Controls 集合後呼叫。Called after a child control is added to the Controls collection of the Control object.

(繼承來源 Control)
AddParsedSubObject(Object)

通知伺服器控制項,XML 或 HTML 項目已剖析,並將項目加入伺服器控制項的 ControlCollection 物件中。Notifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's ControlCollection object.

(繼承來源 Control)
ApplyStyle(Style)

將指定樣式的任何非空白項目加入到 Web 控制項中,覆寫控制項的任何現有的樣式項目。Copies any nonblank elements of the specified style to the Web control, overwriting any existing style elements of the control. 這個方法主要由控制項開發人員使用。This method is primarily used by control developers.

(繼承來源 WebControl)
ApplyStyleSheetSkin(Page)

將頁面樣式表中所定義的樣式屬性套用至控制項。Applies the style properties defined in the page style sheet to the control.

(繼承來源 Control)
BeginRenderTracing(TextWriter, Object)

開始進行轉譯資料的設計階段追蹤。Begins design-time tracing of rendering data.

(繼承來源 Control)
BuildProfileTree(String, Boolean)

收集伺服器控制項的相關資訊,並在頁面啟用追蹤時將此資訊傳遞至 Trace 屬性以顯示之。Gathers information about the server control and delivers it to the Trace property to be displayed when tracing is enabled for the page.

(繼承來源 Control)
ChangeMode(DetailsViewMode)

DetailsView 控制項切換為指定的模式。Switches the DetailsView control to the specified mode.

ClearCachedClientID()

將快取的 ClientID 值設定為 nullSets the cached ClientID value to null.

(繼承來源 Control)
ClearChildControlState()

刪除伺服器控制項之子控制項的控制項狀態資訊。Deletes the control-state information for the server control's child controls.

(繼承來源 Control)
ClearChildState()

刪除所有伺服器控制項之子控制項的檢視狀態和控制項狀態資訊。Deletes the view-state and control-state information for all the server control's child controls.

(繼承來源 Control)
ClearChildViewState()

刪除所有伺服器控制項之子控制項的檢視狀態資訊。Deletes the view-state information for all the server control's child controls.

(繼承來源 Control)
ClearEffectiveClientIDMode()

將目前的控制項執行個體和任何子控制項的 ClientIDMode 屬性設定為 InheritSets the ClientIDMode property of the current control instance and of any child controls to Inherit.

(繼承來源 Control)
ConfirmInitState()

設定資料繫結控制項之初始化的狀態。Sets the initialized state of the data-bound control.

(繼承來源 BaseDataBoundControl)
CopyBaseAttributes(WebControl)

將不被 Style 物件封裝的屬性從指定的 Web 伺服器控制項複製到呼叫這個方法的 Web 伺服器控制項上。Copies the properties not encapsulated by the Style object from the specified Web server control to the Web server control that this method is called from. 這個方法主要由控制項開發人員使用。This method is used primarily by control developers.

(繼承來源 WebControl)
CreateAutoGeneratedRow(AutoGeneratedFieldProperties)

使用指定的欄位屬性,建立表示自動產生資料列欄位的 AutoGeneratedField 物件。Creates an AutoGeneratedField object that represents an automatically generated row field using the specified field properties.

CreateAutoGeneratedRows(Object)

針對指定的資料項目,建立一組自動產生的資料列欄位。Creates a set of automatically generated row fields for the specified data item.

CreateChildControls()

根據儲存在檢視狀態中的值,建立用來呈現複合資料繫結控制項的控制項階層架構。Creates the control hierarchy that is used to render a composite data-bound control based on the values that are stored in view state.

(繼承來源 CompositeDataBoundControl)
CreateChildControls(IEnumerable, Boolean)

建立用來呈現 DetailsView 控制項的控制階層架構。Creates the control hierarchy used to render the DetailsView control.

CreateControlCollection()

建立新的 ControlCollection 物件來保存伺服器控制項的子控制項 (常值和伺服器)。Creates a new ControlCollection object to hold the child controls (both literal and server) of the server control.

(繼承來源 Control)
CreateControlStyle()

建立 DetailsView 控制項的預設資料表樣式物件。Creates a default table style object for the DetailsView control.

CreateDataSourceSelectArguments()

建立傳遞至 Select 命令的 DataSourceSelectArguments 物件。Creates the DataSourceSelectArguments object that gets passed to the Select command.

CreateFieldSet(Object, Boolean)

建立自動產生與使用者定義資料列欄位的完整集合,以便用來產生控制階層架構。Creates the complete set of automatically generated and user-defined row fields used to generate the control hierarchy.

CreateRow(Int32, DataControlRowType, DataControlRowState)

建立使用指定項目索引、資料列型別和資料列狀態的 DetailsViewRow 物件。Creates a DetailsViewRow object using the specified item index, row type, and row state.

CreateTable()

建立 DetailsView 控制項的包含資料表。Creates the containing table for the DetailsView control.

DataBind()

呼叫基底類別的 DataBind() 方法。Calls the DataBind() method of the base class.

DataBind(Boolean)

使用會引發 DataBinding 事件的選項,繫結資料來源至叫用的伺服器控制項及其所有子控制項。Binds a data source to the invoked server control and all its child controls with an option to raise the DataBinding event.

(繼承來源 Control)
DataBindChildren()

繫結資料來源至伺服器控制項的子控制項。Binds a data source to the server control's child controls.

(繼承來源 Control)
DeleteItem()

將目前的資料錄從資料來源中刪除。Deletes the current record from the data source.

Dispose()

啟用伺服器控制項,在它從記憶體釋放之前執行最後清除。Enables a server control to perform final clean up before it is released from memory.

(繼承來源 Control)
EndRenderTracing(TextWriter, Object)

結束轉譯資料的設計階段追蹤。Ends design-time tracing of rendering data.

(繼承來源 Control)
EnsureChildControls()

判斷伺服器控制項是否包含子控制項。Determines whether the server control contains child controls. 如果不包含,則建立子控制項。If it does not, it creates child controls.

(繼承來源 Control)
EnsureDataBound()

在確認資料清單控制項需要資料繫結,且已指定有效的資料來源控制項後,呼叫 DataBind() 方法。Calls the DataBind() method after verifying that the data listing control requires data binding and that a valid data source control is specified.

EnsureID()

為尚未指定識別項的控制項,建立識別項。Creates an identifier for controls that do not have an identifier assigned.

(繼承來源 Control)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
ExtractRowValues(IOrderedDictionary, Boolean, Boolean)

擷取每個顯示欄位的值,並將它們儲存在指定的 IOrderedDictionary 物件中。Retrieves the values of each field displayed and stores them in the specified IOrderedDictionary object.

FindControl(String)

在目前命名容器搜尋具有指定 id 參數的伺服器控制項。Searches the current naming container for a server control with the specified id parameter.

(繼承來源 Control)
FindControl(String, Int32)

使用指定的 id 和有助於搜尋之 pathOffset 參數中所指定的整數,在目前的命名容器中搜尋伺服器控制項。Searches the current naming container for a server control with the specified id and an integer, specified in the pathOffset parameter, which aids in the search. 您不應該覆寫這個版本的 FindControl 方法。You should not override this version of the FindControl method.

(繼承來源 Control)
Focus()

設定控制項的輸入焦點。Sets input focus to a control.

(繼承來源 Control)
GetCallbackResult()

傳回以控制項為目標之回呼事件的結果。Returns the result of a callback event that targets a control.

GetCallbackScript(IButtonControl, String)

使用指定的引數,傳回建立的回呼字串。Returns the callback string created using the specified argument.

GetData()

擷取 DataSourceView 物件,資料繫結控制項會用來執行資料作業。Retrieves a DataSourceView object that the data-bound control uses to perform data operations.

(繼承來源 DataBoundControl)
GetDataSource()

擷取與資料繫結控制項關聯的 IDataSource 介面 (如果有的話)。Retrieves the IDataSource interface that the data-bound control is associated with, if any.

(繼承來源 DataBoundControl)
GetDesignModeState()

取得控制項的設計階段資料。Gets design-time data for a control.

(繼承來源 Control)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetRouteUrl(Object)

取得會對應於一組路由參數的 URL。Gets the URL that corresponds to a set of route parameters.

(繼承來源 Control)
GetRouteUrl(RouteValueDictionary)

取得會對應於一組路由參數的 URL。Gets the URL that corresponds to a set of route parameters.

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

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。Gets the URL that corresponds to a set of route parameters and a route name.

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

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。Gets the URL that corresponds to a set of route parameters and a route name.

(繼承來源 Control)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
GetUniqueIDRelativeTo(Control)

傳回指定之控制項 UniqueID 屬性的前置部分。Returns the prefixed portion of the UniqueID property of the specified control.

(繼承來源 Control)
HasControls()

判斷伺服器控制項是否包含任何子控制項。Determines if the server control contains any child controls.

(繼承來源 Control)
HasEvents()

傳回值,指出控制項或任何子控制項的事件是否已註冊。Returns a value indicating whether events are registered for the control or any child controls.

(繼承來源 Control)
InitializePager(DetailsViewRow, PagedDataSource)

建立 DetailsView 控制項的頁面巡覽列。Creates the pager row for the DetailsView control.

InitializeRow(DetailsViewRow, DataControlField)

初始化指定的 DetailsViewRow 物件。Initializes the specified DetailsViewRow object.

InsertItem(Boolean)

將目前的資料錄插入資料來源。Inserts the current record in the data source.

IsBindableType(Type)

判斷指定的資料型別是否可以繫結至 DetailsView 控制項中的欄位。Determines whether the specified data type can be bound to a field in the DetailsView control.

IsLiteralContent()

判斷伺服器控制項是否只儲存常值內容。Determines if the server control holds only literal content.

(繼承來源 Control)
LoadControlState(Object)

載入需要保存之 DetailsView 控制項中屬性的狀態,即使 EnableViewState 屬性設為 falseLoads the state of the properties in the DetailsView control that need to be persisted, even when the EnableViewState property is set to false.

LoadViewState(Object)

載入先前儲存的 DetailsView 控制項檢視狀態。Loads the previously saved view state of the DetailsView control.

MapPathSecure(String)

擷取虛擬絕對路徑或相對路徑所對應至的實體路徑。Retrieves the physical path that a virtual path, either absolute or relative, maps to.

(繼承來源 Control)
MarkAsDataBound()

將檢視狀態中的控制項狀態設為已成功繫結至資料。Sets the state of the control in view state as successfully bound to data.

(繼承來源 DataBoundControl)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
MergeStyle(Style)

將指定樣式的任何非空白項目複製到 Web 控制項,但不覆寫控制項的任何現有樣式項目。Copies any nonblank elements of the specified style to the Web control, but will not overwrite any existing style elements of the control. 這個方法主要由控制項開發人員使用。This method is used primarily by control developers.

(繼承來源 WebControl)
OnBubbleEvent(Object, EventArgs)

決定 Web 伺服器控制項的事件是否要向上傳遞至網頁的使用者介面 (UI) 伺服器控制階層架構。Determines whether the event for the Web server control is passed up the page's user interface (UI) server control hierarchy.

OnCreatingModelDataSource(CreatingModelDataSourceEventArgs)

引發 CreatingModelDataSource 事件。Raises the CreatingModelDataSource event.

(繼承來源 DataBoundControl)
OnDataBinding(EventArgs)

引發 DataBinding 事件。Raises the DataBinding event.

(繼承來源 Control)
OnDataBound(EventArgs)

引發 DataBound 事件。Raises the DataBound event.

(繼承來源 BaseDataBoundControl)
OnDataPropertyChanged()

其中一個基底資料來源識別屬性變更之後,將資料繫結控制項重新繫結至其資料。Rebinds the data-bound control to its data after one of the base data source identification properties changes.

(繼承來源 DataBoundControl)
OnDataSourceViewChanged(Object, EventArgs)

引發 DataSourceViewChanged 事件。Raises the DataSourceViewChanged event.

OnInit(EventArgs)

引發 Init 事件。Raises the Init event.

OnItemCommand(DetailsViewCommandEventArgs)

引發 ItemCommand 事件。Raises the ItemCommand event.

OnItemCreated(EventArgs)

引發 ItemCreated 事件。Raises the ItemCreated event.

OnItemDeleted(DetailsViewDeletedEventArgs)

引發 ItemDeleted 事件。Raises the ItemDeleted event.

OnItemDeleting(DetailsViewDeleteEventArgs)

引發 ItemDeleting 事件。Raises the ItemDeleting event.

OnItemInserted(DetailsViewInsertedEventArgs)

引發 ItemInserted 事件。Raises the ItemInserted event.

OnItemInserting(DetailsViewInsertEventArgs)

引發 ItemInserting 事件。Raises the ItemInserting event.

OnItemUpdated(DetailsViewUpdatedEventArgs)

引發 ItemUpdated 事件。Raises the ItemUpdated event.

OnItemUpdating(DetailsViewUpdateEventArgs)

引發 ItemUpdating 事件。Raises the ItemUpdating event.

OnLoad(EventArgs)

處理 Load 事件。Handles the Load event.

(繼承來源 DataBoundControl)
OnModeChanged(EventArgs)

引發 ModeChanged 事件。Raises the ModeChanged event.

OnModeChanging(DetailsViewModeEventArgs)

引發 ModeChanging 事件。Raises the ModeChanging event.

OnPageIndexChanged(EventArgs)

引發 PageIndexChanged 事件。Raises the PageIndexChanged event.

OnPageIndexChanging(DetailsViewPageEventArgs)

引發 PageIndexChanging 事件。Raises the PageIndexChanging event.

OnPagePreLoad(Object, EventArgs)

設定資料繫結控制項在載入控制項之前的初始化狀態。Sets the initialized state of the data-bound control before the control is loaded.

OnPreRender(EventArgs)

引發 PreRender 事件。Raises the PreRender event.

OnUnload(EventArgs)

引發 Unload 事件。Raises the Unload event.

(繼承來源 Control)
OpenFile(String)

取得用來讀取檔案的 StreamGets a Stream used to read a file.

(繼承來源 Control)
PerformDataBinding(IEnumerable)

將指定的資料來源繫結至 DetailsView 控制項。Binds the specified data source to the DetailsView control.

PerformSelect()

從關聯的資料來源擷取資料。Retrieves data from the associated data source.

(繼承來源 DataBoundControl)
PrepareControlHierarchy()

設定 DetailsView 控制項的控制階層架構。Sets up the control hierarchy of the DetailsView control.

RaiseBubbleEvent(Object, EventArgs)

指派事件的任何來源和它的資訊至控制項的父控制項。Assigns any sources of the event and its information to the control's parent.

(繼承來源 Control)
RaiseCallbackEvent(String)

建立 GetCallbackEventReference 方法中回呼處理常式的引數。Creates the arguments for the callback handler in the GetCallbackEventReference method.

RaisePostBackEvent(String)

回傳至伺服器時引發 DetailsView 控制項的適當事件。Raises the appropriate events for the DetailsView control when it posts back to the server.

RemovedControl(Control)

Control 物件的 Controls 集合中移除子控制項之後呼叫。Called after a child control is removed from the Controls collection of the Control object.

(繼承來源 Control)
Render(HtmlTextWriter)

使用指定的 DetailsView 物件,在用戶端上顯示 HtmlTextWriter 控制項。Displays the DetailsView control on the client using the specified HtmlTextWriter object.

RenderBeginTag(HtmlTextWriter)

將控制項的 HTML 開頭標記呈現在指定的寫入器中。Renders the HTML opening tag of the control to the specified writer. 這個方法主要由控制項開發人員使用。This method is used primarily by control developers.

(繼承來源 WebControl)
RenderChildren(HtmlTextWriter)

將伺服器控制項子系的內容輸出至提供的 HtmlTextWriter 物件,再由這個物件在用戶端上寫入要轉譯的內容。Outputs the content of a server control's children to a provided HtmlTextWriter object, which writes the content to be rendered on the client.

(繼承來源 Control)
RenderContents(HtmlTextWriter)

將控制項的內容呈現在指定的寫入器。Renders the contents of the control to the specified writer. 這個方法主要由控制項開發人員使用。This method is used primarily by control developers.

(繼承來源 WebControl)
RenderControl(HtmlTextWriter)

將伺服器控制項內容輸出至提供的 HtmlTextWriter 物件,並在啟用追蹤時儲存控制項的追蹤資訊。Outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled.

(繼承來源 Control)
RenderControl(HtmlTextWriter, ControlAdapter)

使用提供的 HtmlTextWriter 物件,輸出伺服器控制項內容至提供的 ControlAdapter 物件。Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object.

(繼承來源 Control)
RenderEndTag(HtmlTextWriter)

將控制項的 HTML 結尾標記呈現至指定的寫入器。Renders the HTML closing tag of the control into the specified writer. 這個方法主要由控制項開發人員使用。This method is used primarily by control developers.

(繼承來源 WebControl)
ResolveAdapter()

取得負責呈現指定之控制項的控制項配置器。Gets the control adapter responsible for rendering the specified control.

(繼承來源 Control)
ResolveClientUrl(String)

取得瀏覽器可使用的 URL。Gets a URL that can be used by the browser.

(繼承來源 Control)
ResolveUrl(String)

將 URL 轉換為要求用戶端可使用的 URL。Converts a URL into one that is usable on the requesting client.

(繼承來源 Control)
SaveControlState()

儲存需要保存之 DetailsView 控制項中屬性的狀態,即使 EnableViewState 屬性設為 falseSaves the state of the properties in the DetailsView control that need to be persisted, even when the EnableViewState property is set to false.

SaveViewState()

儲存 DetailsView 控制項的目前檢視狀態。Saves the current view state of the DetailsView control.

SetDesignModeState(IDictionary)

設定控制項的設計階段資料。Sets design-time data for a control.

(繼承來源 Control)
SetPageIndex(Int32)

設定目前顯示於 DetailsView 控制項中之頁面的索引。Sets the index of the currently displayed page in the DetailsView control.

SetRenderMethodDelegate(RenderMethod)

指定事件處理常式委派,以呈現伺服器控制項及其內容至其父控制項。Assigns an event handler delegate to render the server control and its content into its parent control.

(繼承來源 Control)
SetTraceData(Object, Object)

使用追蹤資料機碼和追蹤資料值,設定設計階段期間追蹤呈現資料的追蹤資料。Sets trace data for design-time tracing of rendering data, using the trace data key and the trace data value.

(繼承來源 Control)
SetTraceData(Object, Object, Object)

使用追蹤的物體、追蹤資料機碼和追蹤資料值,設定設計階段期間追蹤呈現資料的追蹤資料。Sets trace data for design-time tracing of rendering data, using the traced object, the trace data key, and the trace data value.

(繼承來源 Control)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
TrackViewState()

標記起點,從此點開始追蹤並儲存 DetailsView 控制項的檢視狀態變更。Marks the starting point to begin tracking and saving view-state changes to the DetailsView control.

UpdateItem(Boolean)

更新資料來源中目前的資料錄。Updates the current record in the data source.

ValidateDataSource(Object)

驗證資料繫結控制項繫結至的物件是該資料繫結控制項所使用的物件。Verifies that the object a data-bound control binds to is one it can work with.

(繼承來源 DataBoundControl)

事件

CallingDataMethods

正在呼叫資料方法時發生。Occurs when data methods are being called.

(繼承來源 DataBoundControl)
CreatingModelDataSource

正在建立 ModelDataSource 物件時發生。Occurs when the ModelDataSource object is being created.

(繼承來源 DataBoundControl)
DataBinding

發生於伺服器控制項繫結至資料來源時。Occurs when the server control binds to a data source.

(繼承來源 Control)
DataBound

在伺服器控制項繫結至資料來源之後發生。Occurs after the server control binds to a data source.

(繼承來源 BaseDataBoundControl)
Disposed

發生於伺服器控制項從記憶體釋放時,這是在要求 ASP.NET 網頁時,伺服器控制項生命週期的最後階段。Occurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested.

(繼承來源 Control)
Init

發生於初始化伺服器控制項時,是其生命週期中的第一個步驟。Occurs when the server control is initialized, which is the first step in its lifecycle.

(繼承來源 Control)
ItemCommand

按一下 DetailsView 控制項中的按鈕時會發生這個事件。Occurs when a button within a DetailsView control is clicked.

ItemCreated

DetailsView 控制項中建立記錄時會發生這個事件。Occurs when a record is created in a DetailsView control.

ItemDeleted

發生於按一下 DetailsView 控制項內的 [刪除] 按鈕時,但是在刪除作業之後。Occurs when a Delete button within a DetailsView control is clicked, but after the delete operation.

ItemDeleting

發生於按一下 DetailsView 控制項內的 [刪除] 按鈕時,但是在刪除作業之前。Occurs when a Delete button within a DetailsView control is clicked, but before the delete operation.

ItemInserted

發生於按一下 DetailsView 控制項內的 [插入] 按鈕時,但是在插入作業之後。Occurs when an Insert button within a DetailsView control is clicked, but after the insert operation.

ItemInserting

發生於按一下 DetailsView 控制項內的 [插入] 按鈕,但是在插入作業之前。Occurs when an Insert button within a DetailsView control is clicked, but before the insert operation.

ItemUpdated

發生於按一下 DetailsView 控制項內的 [更新] 按鈕時,但在更新作業之後。Occurs when an Update button within a DetailsView control is clicked, but after the update operation.

ItemUpdating

發生於按一下 DetailsView 控制項內的 [更新] 按鈕時,但在更新作業之前。Occurs when an Update button within a DetailsView control is clicked, but before the update operation.

Load

發生於載入伺服器控制項至 Page 物件時。Occurs when the server control is loaded into the Page object.

(繼承來源 Control)
ModeChanged

發生於 DetailsView 控制項嘗試在編輯、插入和唯讀模式之間變更,但是在 CurrentMode 屬性更新之後。Occurs when a DetailsView control attempts to change between edit, insert, and read-only mode, but after the CurrentMode property is updated.

ModeChanging

發生於 DetailsView 控制項嘗試在編輯、插入和唯讀模式之間變更,但是在 CurrentMode 屬性更新之前。Occurs when a DetailsView control attempts to change between edit, insert, and read-only mode, but before the CurrentMode property is updated.

PageIndexChanged

發生於 PageIndex 屬性值在分頁作業之後變更時。Occurs when the value of the PageIndex property changes after a paging operation.

PageIndexChanging

發生於 PageIndex 屬性值在分頁作業前變更時。Occurs when the value of the PageIndex property changes before a paging operation.

PreRender

Control 物件載入之後但在呈現之前發生。Occurs after the Control object is loaded but prior to rendering.

(繼承來源 Control)
Unload

發生於伺服器控制項從記憶體卸載時。Occurs when the server control is unloaded from memory.

(繼承來源 Control)

明確介面實作

IAttributeAccessor.GetAttribute(String)

使用指定的名稱,取得 Web 控制項的屬性。Gets an attribute of the Web control with the specified name.

(繼承來源 WebControl)
IAttributeAccessor.SetAttribute(String, String)

將 Web 控制項的屬性設定為指定的名稱和值。Sets an attribute of the Web control to the specified name and value.

(繼承來源 WebControl)
ICallbackContainer.GetCallbackScript(IButtonControl, String)

建立 DetailsView 控制項的回呼指令碼。Creates the callback script for the DetailsView control.

ICallbackEventHandler.GetCallbackResult()

請參閱 GetCallbackResult() 方法。See the method GetCallbackResult().

ICallbackEventHandler.RaiseCallbackEvent(String)

使用指定的引數引發回呼事件。Raises the callback event using the specified arguments.

IControlBuilderAccessor.ControlBuilder

如需這個成員的說明,請參閱 ControlBuilderFor a description of this member, see ControlBuilder.

(繼承來源 Control)
IControlDesignerAccessor.GetDesignModeState()

如需這個成員的說明,請參閱 GetDesignModeState()For a description of this member, see GetDesignModeState().

(繼承來源 Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

如需這個成員的說明,請參閱 SetDesignModeState(IDictionary)For a description of this member, see SetDesignModeState(IDictionary).

(繼承來源 Control)
IControlDesignerAccessor.SetOwnerControl(Control)

如需這個成員的說明,請參閱 SetOwnerControl(Control)For a description of this member, see SetOwnerControl(Control).

(繼承來源 Control)
IControlDesignerAccessor.UserData

如需這個成員的說明,請參閱 UserDataFor a description of this member, see UserData.

(繼承來源 Control)
IDataBindingsAccessor.DataBindings

如需這個成員的說明,請參閱 DataBindingsFor a description of this member, see DataBindings.

(繼承來源 Control)
IDataBindingsAccessor.HasDataBindings

如需這個成員的說明,請參閱 HasDataBindingsFor a description of this member, see HasDataBindings.

(繼承來源 Control)
IDataBoundControl.DataKeyNames

如需這個屬性的說明,請參閱 DataKeyNamesFor a description of this property, see DataKeyNames.

IDataBoundControl.DataMember

如需這個屬性的說明,請參閱 DataMemberFor a description of this property, see DataMember.

IDataBoundControl.DataSource

如需這個屬性的說明,請參閱 DataSourceFor a description of this property, see DataSource.

IDataBoundControl.DataSourceID

如需這個屬性的說明,請參閱 DataSourceIDFor a description of this property, see DataSourceID.

IDataBoundControl.DataSourceObject

如需這個屬性的說明,請參閱 DataSourceObjectFor a description of this property, see DataSourceObject.

IDataBoundItemControl.DataKey

如需這個屬性的說明,請參閱 DataKeyFor a description of this property, see DataKey.

IDataBoundItemControl.Mode

如需這個屬性的說明,請參閱 ModeFor a description of this property, see Mode.

IDataItemContainer.DataItemIndex

如需這個成員的說明,請參閱 DataItemIndexFor a description of this member, see DataItemIndex.

IDataItemContainer.DisplayIndex

如需這個成員的說明,請參閱 DisplayIndexFor a description of this member, see DisplayIndex.

IExpressionsAccessor.Expressions

如需這個成員的說明,請參閱 ExpressionsFor a description of this member, see Expressions.

(繼承來源 Control)
IExpressionsAccessor.HasExpressions

如需這個成員的說明,請參閱 HasExpressionsFor a description of this member, see HasExpressions.

(繼承來源 Control)
IFieldControl.FieldsGenerator

如需這個屬性的說明,請參閱 FieldsGeneratorFor a description of this property, see FieldsGenerator.

IParserAccessor.AddParsedSubObject(Object)

如需這個成員的說明,請參閱 AddParsedSubObject(Object)For a description of this member, see AddParsedSubObject(Object).

(繼承來源 Control)
IPostBackContainer.GetPostBackOptions(IButtonControl)

如需這個成員的說明,請參閱 GetPostBackOptions(IButtonControl)For a description of this member, see GetPostBackOptions(IButtonControl).

IPostBackEventHandler.RaisePostBackEvent(String)

如需這個成員的說明,請參閱 RaisePostBackEvent(String)For a description of this member, see RaisePostBackEvent(String).

擴充方法

EnablePersistedSelection(BaseDataBoundControl)
已過時。

啟用要保存於資料控制項中且支援選取和分頁的選項。Enables selection to be persisted in data controls that support selection and paging.

FindDataSourceControl(Control)

傳回與指定之控制項的資料控制項相關聯的資料來源。Returns the data source that is associated with the data control for the specified control.

FindFieldTemplate(Control, String)

傳回在指定之控制項的命名容器中所指定資料行的欄位樣板。Returns the field template for the specified column in the specified control's naming container.

FindMetaTable(Control)

傳回包含資料控制項的中繼資料表物件。Returns the metatable object for the containing data control.

GetDefaultValues(INamingContainer)

取得所指定資料控制項的預設值集合。Gets the collection of the default values for the specified data control.

GetMetaTable(INamingContainer)

取得所指定資料控制項中的資料表中繼資料。Gets the table metadata for the specified data control.

SetMetaTable(INamingContainer, MetaTable)

設定所指定資料控制項中的資料表中繼資料。Sets the table metadata for the specified data control.

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

設定所指定資料控制項的資料表中繼資料及預設值對應。Sets the table metadata and default value mapping for the specified data control.

SetMetaTable(INamingContainer, MetaTable, Object)

設定所指定資料控制項的資料表中繼資料及預設值對應。Sets the table metadata and default value mapping for the specified data control.

TryGetMetaTable(INamingContainer, MetaTable)

判斷資料表中繼資料是否可供使用。Determines whether table metadata is available.

EnableDynamicData(INamingContainer, Type)

針對指定的資料控制項啟用動態資料行為。Enables Dynamic Data behavior for the specified data control.

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

針對指定的資料控制項啟用動態資料行為。Enables Dynamic Data behavior for the specified data control.

EnableDynamicData(INamingContainer, Type, Object)

針對指定的資料控制項啟用動態資料行為。Enables Dynamic Data behavior for the specified data control.

適用於

另請參閱