SqlDataSource SqlDataSource SqlDataSource SqlDataSource Class

定義

表示資料繫結控制項的 SQL 資料庫。Represents an SQL database to data-bound controls.

public ref class SqlDataSource : System::Web::UI::DataSourceControl
[System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.SqlDataSource))]
public class SqlDataSource : System.Web.UI.DataSourceControl
type SqlDataSource = class
    inherit DataSourceControl
Public Class SqlDataSource
Inherits DataSourceControl
繼承
衍生
屬性

範例

本節包含四個程式碼範例:This section contains four code examples:

  • 第一個程式碼範例示範如何使用宣告式語法, 從GridView控制項中的 SQL Server 顯示資料。The first code example demonstrates how to display data from SQL Server in a GridView control using declarative syntax.

  • 第二個程式碼範例示範如何使用宣告式語法, 在GridView控制項中顯示 ODBC 相容資料庫的資料。The second code example demonstrates how to display data from an ODBC-compliant database in a GridView control using declarative syntax.

  • 第三個程式碼範例示範如何顯示和更新GridView控制項中的資料。The third code example demonstrates how to display and update data in a GridView control.

  • 第四個程式碼範例示範如何顯示和更新DropDownList控制項中的資料。The fourth code example demonstrates how to display and update data in a DropDownList control.

    注意

    這些範例示範如何使用宣告式語法進行資料存取。These examples show how to use declarative syntax for data access. 如需如何使用程式碼 (而不是標記) 來存取資料的相關資訊, 請參閱存取 Visual Studio 中的資料For information about how to access data by using code instead of markup, see Accessing data in Visual Studio.

下列程式碼範例示範如何以宣告方式SqlDataSource使用控制項, 從 SQL Server 取出資料, 並將它顯示GridView在控制項中。The following code example demonstrates how to use a SqlDataSource control declaratively to retrieve data from SQL Server and display it in a 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">

      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          DataSourceMode="DataReader"
          ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
          SelectCommand="SELECT FirstName, LastName, Title FROM Employees">
      </asp:SqlDataSource>

      <asp:GridView
          id="GridView1"
          runat="server"
          DataSourceID="SqlDataSource1">
      </asp:GridView>

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

      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          DataSourceMode="DataReader"
          ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
          SelectCommand="SELECT FirstName, LastName, Title FROM Employees">
      </asp:SqlDataSource>

      <asp:GridView
          id="GridView1"
          runat="server"
          DataSourceID="SqlDataSource1">
      </asp:GridView>

    </form>
  </body>
</html>

下列程式碼範例示範如何以宣告方式SqlDataSource使用控制項, 從 ODBC 相容的資料庫中取出資料, 並將GridView它顯示在控制項中。The following code example demonstrates how to use a SqlDataSource control declaratively to retrieve data from an ODBC-compliant database and display it in a GridView control. 屬性是 ODBC 之 .NET Framework Data Provider 的名稱, 也就是System.Data.OdbcProviderNameThe ProviderName property is the name of the .NET Framework Data Provider for ODBC, which is System.Data.Odbc.

<%@ 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>
    <!-- This example uses a Northwind database that is hosted by an ODBC-compliant
         database. To run this sample, create an ODBC DSN to any database that hosts
         the Northwind database, including Microsoft SQL Server or Microsoft Access,
         change the name of the DSN in the ConnectionString, and view the page.
    -->
    <form id="form1" runat="server">

      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          ProviderName="System.Data.Odbc"
          DataSourceMode="DataReader"
          ConnectionString="dsn=myodbc3dsn;"
          SelectCommand="SELECT FirstName, LastName, Title FROM Employees">
      </asp:SqlDataSource>

      <asp:GridView
          id="GridView1"
          runat="server"
          DataSourceID="SqlDataSource1">
      </asp:GridView>

    </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>
    <!-- This example uses a Northwind database that is hosted by an ODBC-compliant
         database. To run this sample, create an ODBC DSN to any database that hosts
         the Northwind database, including Microsoft SQL Server or Microsoft Access,
         change the name of the DSN in the ConnectionString, and view the page.
    -->
    <form id="form1" runat="server">

      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          ProviderName="System.Data.Odbc"
          DataSourceMode="DataReader"
          ConnectionString="dsn=myodbc3dsn;"
          SelectCommand="SELECT FirstName, LastName, Title FROM Employees">
      </asp:SqlDataSource>

      <asp:GridView
          id="GridView1"
          runat="server"
          DataSourceID="SqlDataSource1">
      </asp:GridView>

    </form>
  </body>
</html>

下列程式碼範例示範GridView控制項的常見顯示和更新案例。The following code example demonstrates a common display and update scenario with the GridView control. 如同先前的範例, Northwind 資料庫中的資料會顯示在GridView控制項中。As with the previous examples, data from the Northwind database is displayed in the GridView control. 此外, 因為UpdateCommand已指定屬性, AutoGenerateEditButton而且屬性設定為true, 所以您可以不使用其他程式碼來編輯和更新記錄。Additionally, because an UpdateCommand property is specified and the AutoGenerateEditButton property is set to true, you can edit and update the records with no additional code. Update UpdateParameters GridView 控制項會自動處理將參數加入至集合, 並在按一下控制項中的 [更新] 按鈕時呼叫方法。 GridViewThe GridView control automatically handles adding parameters to the UpdateParameters collection and calls the Update method when the Update button in the GridView control is clicked.

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

      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          DataSourceMode="DataSet"
          ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
          SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees"
          UpdateCommand="Update Employees SET FirstName=@FirstName,LastName=@LastName,Title=@Title WHERE EmployeeID=@EmployeeID">
      </asp:SqlDataSource>

      <asp:GridView
          id="GridView1"
          runat="server"
          AutoGenerateColumns="False"
          DataKeyNames="EmployeeID"
          AutoGenerateEditButton="True"
          DataSourceID="SqlDataSource1">
          <columns>
              <asp:BoundField HeaderText="First Name" DataField="FirstName" />
              <asp:BoundField HeaderText="Last Name" DataField="LastName" />
              <asp:BoundField HeaderText="Title" DataField="Title" />
          </columns>

      </asp:GridView>

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

      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          DataSourceMode="DataSet"
          ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
          SelectCommand="SELECT EmployeeID,FirstName,LastName,Title FROM Employees"
          UpdateCommand="Update Employees SET FirstName=@FirstName,LastName=@LastName,Title=@Title WHERE EmployeeID=@EmployeeID">
      </asp:SqlDataSource>

      <asp:GridView
          id="GridView1"
          runat="server"
          AutoGenerateColumns="False"
          DataKeyNames="EmployeeID"
          AutoGenerateEditButton="True"
          DataSourceID="SqlDataSource1">
          <columns>
              <asp:BoundField HeaderText="First Name" DataField="FirstName" />
              <asp:BoundField HeaderText="Last Name" DataField="LastName" />
              <asp:BoundField HeaderText="Title" DataField="Title" />
          </columns>

      </asp:GridView>
    </form>
  </body>
</html>

下列程式碼範例示範DropDownListTextBox控制項的常見顯示和更新案例。The following code example demonstrates a common display and update scenario with the DropDownList and TextBox controls. 控制項不會自動將更新參數新增UpdateParameters至集合, 也不會Update呼叫方法, 因此您必須這麼做。 DropDownListThe DropDownList control does not automatically add update parameters to the UpdateParameters collection nor call the Update method, so you must do so. 更新參數是以宣告方式指定, 您可以加入事件處理常式, 以便Update在引發事件時執行作業。The update parameters are specified declaratively and you can add an event handler to perform the Update operation when an event is raised.

重要

此範例包含可接受使用者輸入的文字方塊, 這是潛在的安全性威脅。This example includes a text box that accepts user input, which is a potential security threat. 根據預設,ASP.NET Web 網頁會驗證使用者輸入未包含指令碼或 HTML 項目。By default, ASP.NET Web pages validate that user input does not include script or HTML elements. 如需詳細資訊,請參閱 Script Exploits Overview (指令碼攻擊概觀)。For more information, see Script Exploits Overview.

<%@Page  Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
 private void On_Click(Object source, EventArgs e) {
    try {
        SqlDataSource1.Update();
    }
    catch (Exception except) {
        // Handle the Exception.
    }

    Label2.Text="The record was updated successfully!";
 }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
          SelectCommand="SELECT EmployeeID, LastName, Address FROM Employees"
          UpdateCommand="UPDATE Employees SET Address=@Address WHERE EmployeeID=@EmployeeID">
          <UpdateParameters>
              <asp:ControlParameter Name="Address" ControlId="TextBox1" PropertyName="Text"/>
              <asp:ControlParameter Name="EmployeeID" ControlId="DropDownList1" PropertyName="SelectedValue"/>
          </UpdateParameters>
      </asp:SqlDataSource>

      <asp:DropDownList
          id="DropDownList1"
          runat="server"
          DataTextField="LastName"
          DataValueField="EmployeeID"
          DataSourceID="SqlDataSource1">
      </asp:DropDownList>

      <br />
      <asp:Label id="Label1" runat="server" Text="Enter a new address for the selected user."
        AssociatedControlID="TextBox1" />
      <asp:TextBox id="TextBox1" runat="server" />
      <asp:Button id="Submit" runat="server" Text="Submit" OnClick="On_Click" />

      <br /><asp:Label id="Label2" runat="server" Text="" />

    </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 On_Click(ByVal source As Object, ByVal e As EventArgs)
    Try
        SqlDataSource1.Update()
    Catch except As Exception
        ' Handle the Exception.
    End Try

    Label2.Text="The record was updated successfully!"

 End Sub 'On_Click
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
          SelectCommand="SELECT EmployeeID, LastName, Address FROM Employees"
          UpdateCommand="UPDATE Employees SET Address=@Address WHERE EmployeeID=@EmployeeID">
          <UpdateParameters>
              <asp:ControlParameter Name="Address" ControlId="TextBox1" PropertyName="Text"/>
              <asp:ControlParameter Name="EmployeeID" ControlId="DropDownList1" PropertyName="SelectedValue"/>
          </UpdateParameters>
      </asp:SqlDataSource>

      <asp:DropDownList
          id="DropDownList1"
          runat="server"
          DataTextField="LastName"
          DataValueField="EmployeeID"
          DataSourceID="SqlDataSource1">
      </asp:DropDownList>

      <br />
      <asp:Label id="Label1" runat="server" Text="Enter a new address for the selected user."
        AssociatedControlID="TextBox1" />
      <asp:TextBox id="TextBox1" runat="server" />
      <asp:Button id="Submit" runat="server" Text="Submit" OnClick="On_Click" />

      <br /><asp:Label id="Label2" runat="server" Text="" />
    </form>
  </body>
</html>

備註

本主題內容:In this topic:

簡介Introduction

SqlDataSource資料來源控制項會將 SQL 關係資料庫中的資料表示為資料繫結控制項。The SqlDataSource data source control represents data in an SQL relational database to data-bound controls. 您可以使用SqlDataSource控制項搭配資料繫結控制項, 從關係資料庫抓取資料, 並在幾乎或完全不使用程式碼的情況下, 顯示、編輯和排序網頁上的資料。You can use the SqlDataSource control in conjunction with a data-bound control to retrieve data from a relational database and to display, edit, and sort data on a Web page with little or no code.

資料連接Data Connections

若要連接到資料庫, 您必須將ConnectionString屬性設定為有效的連接字串。To connect to a database, you must set the ConnectionString property to a valid connection string. OleDb SqlClient OracleClient Odbc可以支援任何可以使用 ADO.NET 提供者連接到的 SQL 關係資料庫, 例如、、或提供者。 SqlDataSourceThe SqlDataSource can support any SQL relational database that can be connected to using an ADO.NET provider, such as the SqlClient, OleDb, Odbc, or OracleClient provider. 如需如何保護連接字串的詳細資訊, 請參閱如何:使用資料來源控制項時保護連接字串。For information about how to secure connection strings, see How To: Secure Connection Strings when Using Data Source Controls.

若要從基礎資料庫中取出資料, 請SelectCommand使用 SQL 查詢來設定屬性。To retrieve data from an underlying database, set the SelectCommand property with an SQL query. 如果與相關聯的SqlDataSource資料庫支援預存程式, 您可以SelectCommand將屬性設定為預存程式的名稱。If the database that the SqlDataSource is associated with supports stored procedures, you can set the SelectCommand property to the name of a stored procedure. 您所指定的 SQL 查詢也可以是參數化查詢。The SQL query that you specify can also be a parameterized query. 您可以將Parameter與參數化查詢相關聯的物件加入SelectParameters至集合。You can add Parameter objects that are associated with a parameterized query to the SelectParameters collection. 如需參數化 SQL 查詢及其語法的詳細資訊, 請參閱使用參數搭配資料來源控制項進行篩選For more information about parameterized SQL queries and their syntax, see Using Parameters with Data Source Controls for Filtering.

每當呼叫SqlDataSource方法時, 控制項會抓取資料。SelectThe SqlDataSource control retrieves data whenever the Select method is called. 這個方法可讓您以程式設計方式存取由SelectMethod屬性所指定的方法。This method provides programmatic access to the method that is specified by SelectMethod property. 當呼叫其SqlDataSource Select 方法時,系結至的控制項會DataBind自動呼叫方法。The Select method is automatically called by controls that are bound to the SqlDataSource when their DataBind method is called. 如果您設定資料DataSourceID繫結控制項的屬性, 控制項會視需要自動系結至資料來源中的資料。If you set the DataSourceID property of a data-bound control, the control automatically binds to data from the data source, as required. 設定屬性是將ObjectDataSource控制項系結至資料繫結控制項的建議方法。 DataSourceIDSetting the DataSourceID property is the recommended method for binding an ObjectDataSource control to a data-bound control. 或者, 您可以使用DataSource屬性, 但您必須明確地呼叫資料繫結控制項的DataBind方法。Alternatively, you can use the DataSource property, but then you must explicitly call the DataBind method of the data-bound control. 可以SqlDataSource使用的一些資料繫結控制項範例包括DataGridDetailsViewDataListDropDownListSome examples of data-bound controls that can use SqlDataSource are DataGrid, DetailsView, DataList, and DropDownList. 您可以隨時以Select程式設計方式呼叫方法, 以從基礎資料庫中取出資料。You can call the Select method programmatically at any time to retrieve data from the underlying database.

在宣告式和程式設計 ASP.NET 案例中, 您DataSourceID可以將資料繫結控制項的屬性設為SqlDataSource控制項的識別碼。In declarative and programmatic ASP.NET scenarios, you can set the DataSourceID property of the data-bound control to the ID of the SqlDataSource control. 您也可以將SqlDataSource類別的實例指派給資料繫結控制項的DataSource屬性。You can also assign an instance of the SqlDataSource class to the DataSource property of the data-bound control. 如需將資料繫結控制項系結至資料來源控制項的詳細資訊, 請參閱ASP.NET 資料存取選項For more information about binding data-bound control to data source controls, see ASP.NET Data Access Options.

執行資料作業Performing Data Operations

視基礎資料庫產品的功能和SqlDataSource類別的實例設定而定, 您可以執行資料作業, 例如更新、插入和刪除。Depending on the capabilities of the underlying database product and the configuration of the instance of the SqlDataSource class, you can perform data operations, such as updates, inserts, and deletes. 若要執行這些資料作業, 請針對您想要執行的作業, 設定適當的命令文字和任何相關聯的參數。To perform these data operations, set the appropriate command text and any associated parameters for the operation that you want to perform. 例如, 如果是更新作業, 請將UpdateCommand屬性設定為 SQL 字串或預存程式的名稱, 並將任何必要的參數加入UpdateParameters至集合。For example, for an update operation, set the UpdateCommand property to an SQL string or the name of a stored procedure and add any required parameters to the UpdateParameters collection. 此更新是在呼叫Update方法時執行, 不論是由程式碼明確或由資料繫結控制項自動進行。The update is performed when the Update method is called, either explicitly by your code or automatically by a data-bound control. DeleteInsert作業會遵循相同的一般模式。The same general pattern is followed for Delete and Insert operations.

您在SelectCommandUpdateCommandInsertCommand和屬性中使用的SQL查詢和命令可以參數化。DeleteCommandThe SQL queries and commands that you use in the SelectCommand, UpdateCommand, InsertCommand, and DeleteCommand properties can be parameterized. 這表示查詢或命令可以使用預留位置, 而不是常值, 並將預留位置系結至應用程式或使用者自訂變數。This means that the query or command can use placeholders instead of literal values and bind the placeholders to application or user-defined variables. 您可以將 SQL 查詢中的參數系結至會話變數、在 Web form 頁面的查詢字串上傳遞的值、其他伺服器控制項的屬性值等等。You can bind parameters in SQL queries to Session variables, values that are passed on the query string for a Web Forms page, the property values of other server controls, and more. 如需如何在 SQL 查詢中使用參數搭配的SqlDataSource詳細資訊, 請參閱搭配使用參數與資料來源控制項來篩選使用 SqlDataSource 控制項的參數For more information about how to use parameters in SQL queries with the SqlDataSource, see Using Parameters with Data Source Controls for Filtering and Using Parameters with the SqlDataSource Control.

注意

根據預設, 當您null Select執行命令時, 如果其中一個參數是, 則不會傳回任何資料, 也不會擲回任何例外狀況。By default, if one of the parameters is null when you execute a Select command, no data will be returned and no exception will be thrown. 您可以藉由將CancelSelectOnNullParameter屬性設定為false, 來變更此行為。You can change this behavior by setting the CancelSelectOnNullParameter property to false.

Data ProviderData Provider

根據預設, 此SqlDataSource控制項適用于 SQL Server 的 .NET Framework Data Provider, 但SqlDataSource不 Microsoft SQL Server 特定。By default, the SqlDataSource control works with the .NET Framework Data Provider for SQL Server, but SqlDataSource is not Microsoft SQL Server-specific. 您可以將SqlDataSource控制項連接到有受控 ADO.NET 提供者的任何資料庫產品。You can connect the SqlDataSource control with any database product for which there is a managed ADO.NET provider. System.Data.OleDb提供者搭配使用時SqlDataSource , 可以使用任何 OLE DB 相容的資料庫。When used with the System.Data.OleDb provider, the SqlDataSource can work with any OLE DB-compliant database. System.Data.Odbc提供者SqlDataSource搭配使用時, 可以搭配任何 ODBC 驅動程式和資料庫使用, 包括 IBM DB2、MySQL 和于 postgresql。When used with the System.Data.Odbc provider, the SqlDataSource can be used with any ODBC driver and database, including IBM DB2, MySQL, and PostgreSQL. System.Data.OracleClient提供者搭配使用時SqlDataSource , 可以使用 Oracle 8.1.7 資料庫和更新版本。When used with the System.Data.OracleClient provider, the SqlDataSource can work with Oracle 8.1.7 databases and later. 可允許的提供者清單已在配置DbProviderFactories檔的區段中註冊, 無論是在 machine.config 或 web.config 檔案中。The list of allowable providers is registered in the DbProviderFactories section of the configuration file, either in the Machine.config or Web.config file. 如需詳細資訊, 請參閱使用 SqlDataSource 控制項選取資料For more information, see Selecting Data Using the SqlDataSource Control.

快取Caching

如果您使用SqlDataSource控制項在頁面上顯示資料, 您可以使用資料來源控制項的資料快取功能來增加頁面的效能。If you display data on your page using a SqlDataSource control, you can increase the performance of the page by using the data caching capabilities of the data source control. 快取會減少資料庫伺服器上的處理負載, 而且會佔用 Web 服務器上的記憶體費用;在大部分情況下, 這是很好的取捨。Caching reduces the processing load on the database servers at the expense of memory on the Web server; in most cases, this is a good trade-off. EnableCaching CacheDuration屬性設定為SqlDataSource 時,會自動快取資料,而屬性會設定為在捨棄快取專案之前,快取儲存資料true的秒數。The SqlDataSource automatically caches data when the EnableCaching property is set to true and the CacheDuration property is set to the number of seconds that the cache stores data before the cache entry is discarded. 您也可以指定CacheExpirationPolicy和選擇性SqlCacheDependency的值。You can also specify a CacheExpirationPolicy and an optional SqlCacheDependency value.

其他功能Additional Features

SqlDataSource提供其他功能, 如下表所列。The SqlDataSource provides additional capabilities, as listed in the following table.

功能Capability 需求Requirements
快取Caching true CacheExpirationPolicy DataSet EnableCaching根據您想要用於快取資料的快取行為, CacheDuration將屬性設定為值、屬性設為,以及和屬性。DataSourceModeSet the DataSourceMode property to the DataSet value, the EnableCaching property to true, and the CacheDuration and CacheExpirationPolicy properties according to the caching behavior you want for your cached data.
DeletingDeleting DeleteCommand將屬性設定為用來刪除資料的 SQL 語句。Set the DeleteCommand property to an SQL statement used to delete data. 這個語句通常是參數化的。This statement is typically parameterized.
篩選Filtering 將屬性設定為DataSet值。 DataSourceModeSet the DataSourceMode property to the DataSet value. 將屬性設定為篩選運算式, 以便在呼叫Select方法時用來篩選資料。 FilterExpressionSet the FilterExpression property to a filtering expression used to filter the data when the Select method is called.
插入Inserting InsertCommand將屬性設定為用來插入資料的 SQL 語句。Set the InsertCommand property to an SQL statement used to insert data. 這個語句通常是參數化的。This statement is typically parameterized.
分頁Paging 目前不支援SqlDataSource, 不過有些資料繫結控制項 ( GridView例如) 會在您DataSetDataSourceMode屬性設定為值時支援分頁。Not currently supported by the SqlDataSource, however some data-bound controls, such as GridView, support paging when you set the DataSourceMode property to the DataSet value.
選取Selecting SelectCommand將屬性設定為用來抓取資料的 SQL 語句。Set the SelectCommand property to an SQL statement used to retrieve data.
排序Sorting DataSourceMode 屬性設定為 DataSetSet the DataSourceMode property to DataSet.
UpdatingUpdating UpdateCommand將屬性設定為用來更新資料的 SQL 語句。Set the UpdateCommand property to an SQL statement used to update data. 這個語句通常是參數化的。This statement is typically parameterized.

資料來源檢視Data Source View

如同所有資料來源控制項, SqlDataSource控制項會與資料來源 view 類別相關聯。As with all data source controls, the SqlDataSource control is associated with a data source view class. 控制項只有一個相關聯SqlDataSourceView, 而且一律會命名為TableSqlDataSourceThe SqlDataSource control has only one associated SqlDataSourceView, and it is always named Table.

SqlDataSource控制項沒有視覺呈現, 它會實作為控制項, 讓您可以用宣告方式建立它, 並選擇性地讓它參與狀態管理。There is no visual rendering of the SqlDataSource control; it is implemented as a control so that you can create it declaratively and, optionally, to allow it to participate in state management. 因此, SqlDataSource不支援視覺特徵, 例如EnableThemingSkinID屬性所提供的功能。As a result, the SqlDataSource does not support visual features, such as the ones that are provided by the EnableTheming or SkinID property.

宣告式語法Declarative Syntax

<asp:SqlDataSource  
    CacheDuration="string|Infinite"  
    CacheExpirationPolicy="Absolute|Sliding"  
    CacheKeyDependency="string"  
    CancelSelectOnNullParameter="True|False"  
    ConflictDetection="OverwriteChanges|CompareAllValues"  
    ConnectionString="string"  
    DataSourceMode="DataReader|DataSet"  
    DeleteCommand="string"  
    DeleteCommandType="Text|StoredProcedure"  
    EnableCaching="True|False"  
    EnableTheming="True|False"  
    EnableViewState="True|False"  
    FilterExpression="string"  
    ID="string"  
    InsertCommand="string"  
    InsertCommandType="Text|StoredProcedure"  
    OldValuesParameterFormatString="string"  
    OnDataBinding="DataBinding event handler"  
    OnDeleted="Deleted event handler"  
    OnDeleting="Deleting event handler"  
    OnDisposed="Disposed event handler"  
    OnFiltering="Filtering event handler"  
    OnInit="Init event handler"  
    OnInserted="Inserted event handler"  
    OnInserting="Inserting event handler"  
    OnLoad="Load event handler"  
    OnPreRender="PreRender event handler"  
    OnSelected="Selected event handler"  
    OnSelecting="Selecting event handler"  
    OnUnload="Unload event handler"  
    OnUpdated="Updated event handler"  
    OnUpdating="Updating event handler"  
    ProviderName="string|System.Data.Odbc|System.Data.OleDb|  
        System.Data.OracleClient|System.Data.SqlClient|  
        Microsoft.SqlServerCe.Client"  
    runat="server"  
    SelectCommand="string"  
    SelectCommandType="Text|StoredProcedure"  
    SkinID="string"  
    SortParameterName="string"  
    SqlCacheDependency="string"  
    UpdateCommand="string"  
    UpdateCommandType="Text|StoredProcedure"  
    Visible="True|False"  
>  
        <DeleteParameters>  
                <asp:ControlParameter  
                    ControlID="string"  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    PropertyName="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:CookieParameter  
                    ConvertEmptyStringToNull="True|False"  
                    CookieName="string"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:FormParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    FormField="string"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:Parameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:ProfileParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    PropertyName="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:QueryStringParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    QueryStringField="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:SessionParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    SessionField="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
        </DeleteParameters>  
        <FilterParameters>  
                <asp:ControlParameter  
                    ControlID="string"  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    PropertyName="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:CookieParameter  
                    ConvertEmptyStringToNull="True|False"  
                    CookieName="string"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:FormParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    FormField="string"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:Parameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:ProfileParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    PropertyName="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:QueryStringParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    QueryStringField="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:SessionParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    SessionField="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
        </FilterParameters>  
        <InsertParameters>  
                <asp:ControlParameter  
                    ControlID="string"  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    PropertyName="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:CookieParameter  
                    ConvertEmptyStringToNull="True|False"  
                    CookieName="string"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:FormParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    FormField="string"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:Parameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:ProfileParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    PropertyName="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:QueryStringParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    QueryStringField="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:SessionParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    SessionField="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
        </InsertParameters>  
        <SelectParameters>  
                <asp:ControlParameter  
                    ControlID="string"  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    PropertyName="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:CookieParameter  
                    ConvertEmptyStringToNull="True|False"  
                    CookieName="string"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:FormParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    FormField="string"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:Parameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:ProfileParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    PropertyName="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:QueryStringParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    QueryStringField="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:SessionParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    SessionField="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
        </SelectParameters>  
        <UpdateParameters>  
                <asp:ControlParameter  
                    ControlID="string"  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    PropertyName="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:CookieParameter  
                    ConvertEmptyStringToNull="True|False"  
                    CookieName="string"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:FormParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    FormField="string"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:Parameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:ProfileParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    PropertyName="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:QueryStringParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    QueryStringField="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
                <asp:SessionParameter  
                    ConvertEmptyStringToNull="True|False"  
                    DefaultValue="string"  
                    Direction="Input|Output|InputOutput|ReturnValue"  
                    Name="string"  
                    SessionField="string"  
                    Size="integer"  
                    Type="Empty|Object|DBNull|Boolean|Char|SByte|  
                        Byte|Int16|UInt16|Int32|UInt32|Int64|UInt64|  
                        Single|Double|Decimal|DateTime|String"  
                />  
        </UpdateParameters>  
</asp:SqlDataSource>  

建構函式

SqlDataSource() SqlDataSource() SqlDataSource() SqlDataSource()

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

SqlDataSource(String, String) SqlDataSource(String, String) SqlDataSource(String, String) SqlDataSource(String, String)

使用指定的連接字串和 Select 命令,初始化 SqlDataSource 類別的新執行個體。Initializes a new instance of the SqlDataSource class with the specified connection string and Select command.

SqlDataSource(String, String, String) SqlDataSource(String, String, String) SqlDataSource(String, String, String) SqlDataSource(String, String, String)

使用指定的連接字串和 Select 命令,初始化 SqlDataSource 類別的新執行個體。Initializes a new instance of the SqlDataSource class with the specified connection string and Select command.

屬性

Adapter Adapter Adapter Adapter

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

(Inherited from Control)
AppRelativeTemplateSourceDirectory AppRelativeTemplateSourceDirectory AppRelativeTemplateSourceDirectory AppRelativeTemplateSourceDirectory

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

(Inherited from Control)
BindingContainer BindingContainer BindingContainer BindingContainer

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

(Inherited from Control)
CacheDuration CacheDuration CacheDuration CacheDuration

取得或設定資料來源控制項快取 Select(DataSourceSelectArguments) 方法所擷取之資料的時間長度 (以秒為單位)。Gets or sets the length of time, in seconds, that the data source control caches data that is retrieved by the Select(DataSourceSelectArguments) method.

CacheExpirationPolicy CacheExpirationPolicy CacheExpirationPolicy CacheExpirationPolicy

取得或設定快取到期行為,當與持續期間搭配使用時,用來描述資料來源控制項所使用的快取行為。Gets or sets the cache expiration behavior that, when combined with the duration, describes the behavior of the cache that the data source control uses.

CacheKeyDependency CacheKeyDependency CacheKeyDependency CacheKeyDependency

取得或設定使用者定義的索引鍵相依性,連結至資料來源控制項所建立的所有資料快取物件。Gets or sets a user-defined key dependency that is linked to all data cache objects that are created by the data source control. 當索引鍵過期時,所有快取的物件也會明確過期。All cache objects are explicitly expired when the key is expired.

CancelSelectOnNullParameter CancelSelectOnNullParameter CancelSelectOnNullParameter CancelSelectOnNullParameter

取得或設定值,指出當 SelectParameters 集合中包含的任何參數評估為 null 時,是否取消資料擷取作業。Gets or sets a value indicating whether a data retrieval operation is canceled when any parameter that is contained in the SelectParameters collection evaluates to null.

ChildControlsCreated ChildControlsCreated ChildControlsCreated ChildControlsCreated

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

(Inherited from Control)
ClientID ClientID ClientID ClientID

取得 ASP.NET 產生的伺服器控制項識別項。Gets the server control identifier generated by ASP.NET.

(Inherited from DataSourceControl)
ClientIDMode ClientIDMode ClientIDMode ClientIDMode

這個屬性不會用於資料來源控制項。This property is not used for data source controls.

(Inherited from DataSourceControl)
ClientIDSeparator ClientIDSeparator ClientIDSeparator ClientIDSeparator

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

(Inherited from Control)
ConflictDetection ConflictDetection ConflictDetection ConflictDetection

取得或設定值,指出在作業期間,當基礎資料庫的資料列資料發生變更時,SqlDataSource 控制項如何執行更新和刪除作業。Gets or sets the value indicating how the SqlDataSource control performs updates and deletes when data in a row in the underlying database changes during the time of the operation.

ConnectionString ConnectionString ConnectionString ConnectionString

取得和設定 ADO.NET 提供者特定的連接字串,SqlDataSource 控制項會用來連接至基礎資料庫。Gets or sets the ADO.NET provider-specific connection string that the SqlDataSource control uses to connect to an underlying database.

Context Context Context Context

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

(Inherited from Control)
Controls Controls Controls Controls

取得 ControlCollection 物件,表示 UI 階層架構中指定之伺服器控制項的子控制項。Gets a ControlCollection object that represents the child controls for a specified server control in the UI hierarchy.

(Inherited from DataSourceControl)
DataItemContainer DataItemContainer DataItemContainer DataItemContainer

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

(Inherited from Control)
DataKeysContainer DataKeysContainer DataKeysContainer DataKeysContainer

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

(Inherited from Control)
DataSourceMode DataSourceMode DataSourceMode DataSourceMode

取得或設定 SqlDataSource 控制項用於擷取資料的資料擷取模式。Gets or sets the data retrieval mode that the SqlDataSource control uses to fetch data.

DeleteCommand DeleteCommand DeleteCommand DeleteCommand

取得或設定 SQL 字串,SqlDataSource 控制項會用來刪除基礎資料庫的資料。Gets or sets the SQL string that the SqlDataSource control uses to delete data from the underlying database.

DeleteCommandType DeleteCommandType DeleteCommandType DeleteCommandType

取得或設定值,指出 DeleteCommand 屬性中的文字是 SQL 陳述式還是預存程序的名稱。Gets or sets a value indicating whether the text in the DeleteCommand property is an SQL statement or the name of a stored procedure.

DeleteParameters DeleteParameters DeleteParameters DeleteParameters

取得參數集合,包含與 DeleteCommand 控制項相關聯之 SqlDataSourceView 物件 SqlDataSource 屬性所使用的參數。Gets the parameters collection that contains the parameters that are used by the DeleteCommand property from the SqlDataSourceView object that is associated with the SqlDataSource control.

DesignMode DesignMode DesignMode DesignMode

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

(Inherited from Control)
EnableCaching EnableCaching EnableCaching EnableCaching

取得或設定值,指出 SqlDataSource 控制項是否啟用了資料快取。Gets or sets a value indicating whether the SqlDataSource control has data caching enabled.

EnableTheming EnableTheming EnableTheming EnableTheming

取得值,指出這個控制項是否支援佈景主題。Gets a value indicating whether this control supports themes.

(Inherited from DataSourceControl)
EnableViewState EnableViewState EnableViewState 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.

(Inherited from Control)
Events Events Events Events

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

(Inherited from Control)
FilterExpression FilterExpression FilterExpression FilterExpression

取得或設定當呼叫 Select(DataSourceSelectArguments) 時會套用的篩選運算式。Gets or sets a filtering expression that is applied when the Select(DataSourceSelectArguments) method is called.

FilterParameters FilterParameters FilterParameters FilterParameters

取得與 FilterExpression 字串中任何參數替代符號相關聯的參數集合。Gets a collection of parameters that are associated with any parameter placeholders that are in the FilterExpression string.

HasChildViewState HasChildViewState HasChildViewState HasChildViewState

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

(Inherited from Control)
IControlBuilderAccessor.ControlBuilder IControlBuilderAccessor.ControlBuilder IControlBuilderAccessor.ControlBuilder IControlBuilderAccessor.ControlBuilder

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

(Inherited from Control)
IControlDesignerAccessor.UserData IControlDesignerAccessor.UserData IControlDesignerAccessor.UserData IControlDesignerAccessor.UserData

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

(Inherited from Control)
ID ID ID ID

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

(Inherited from Control)
IDataBindingsAccessor.DataBindings IDataBindingsAccessor.DataBindings IDataBindingsAccessor.DataBindings IDataBindingsAccessor.DataBindings

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

(Inherited from Control)
IDataBindingsAccessor.HasDataBindings IDataBindingsAccessor.HasDataBindings IDataBindingsAccessor.HasDataBindings IDataBindingsAccessor.HasDataBindings

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

(Inherited from Control)
IdSeparator IdSeparator IdSeparator IdSeparator

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

(Inherited from Control)
IExpressionsAccessor.Expressions IExpressionsAccessor.Expressions IExpressionsAccessor.Expressions IExpressionsAccessor.Expressions

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

(Inherited from Control)
IExpressionsAccessor.HasExpressions IExpressionsAccessor.HasExpressions IExpressionsAccessor.HasExpressions IExpressionsAccessor.HasExpressions

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

(Inherited from Control)
IListSource.ContainsListCollection IListSource.ContainsListCollection IListSource.ContainsListCollection IListSource.ContainsListCollection

指示資料來源控制項是否與一個或多個資料清單產生關聯。Indicates whether the data source control is associated with one or more lists of data.

(Inherited from DataSourceControl)
InsertCommand InsertCommand InsertCommand InsertCommand

取得或設定 SQL 字串,SqlDataSource 控制項會用來將資料插入基礎資料庫。Gets or sets the SQL string that the SqlDataSource control uses to insert data into the underlying database.

InsertCommandType InsertCommandType InsertCommandType InsertCommandType

取得或設定值,指出 InsertCommand 屬性中的文字是 SQL 陳述式還是預存程序的名稱。Gets or sets a value indicating whether the text in the InsertCommand property is an SQL statement or the name of a stored procedure.

InsertParameters InsertParameters InsertParameters InsertParameters

取得參數集合,包含與 InsertCommand 控制項相關聯之 SqlDataSourceView 物件 SqlDataSource 屬性所使用的參數。Gets the parameters collection that contains the parameters that are used by the InsertCommand property from the SqlDataSourceView object that is associated with the SqlDataSource control.

IsChildControlStateCleared IsChildControlStateCleared IsChildControlStateCleared IsChildControlStateCleared

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

(Inherited from Control)
IsTrackingViewState IsTrackingViewState IsTrackingViewState IsTrackingViewState

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

(Inherited from Control)
IsViewStateEnabled IsViewStateEnabled IsViewStateEnabled IsViewStateEnabled

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

(Inherited from Control)
LoadViewStateByID LoadViewStateByID LoadViewStateByID LoadViewStateByID

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

(Inherited from Control)
NamingContainer NamingContainer NamingContainer 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.

(Inherited from Control)
OldValuesParameterFormatString OldValuesParameterFormatString OldValuesParameterFormatString OldValuesParameterFormatString

取得或設定格式字串,套用至傳遞給 Delete()Update() 方法之任何參數的名稱。Gets or sets a format string to apply to the names of any parameters that are passed to the Delete() or Update() method.

Page Page Page Page

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

(Inherited from Control)
Parent Parent Parent Parent

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

(Inherited from Control)
ProviderName ProviderName ProviderName ProviderName

取得或設定 .NET Framework 資料提供者的名稱,SqlDataSource 控制項會用來連接至基礎資料來源。Gets or sets the name of the .NET Framework data provider that the SqlDataSource control uses to connect to an underlying data source.

RenderingCompatibility RenderingCompatibility RenderingCompatibility RenderingCompatibility

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

(Inherited from Control)
SelectCommand SelectCommand SelectCommand SelectCommand

取得或設定 SQL 字串,SqlDataSource 控制項會用來擷取基礎資料庫的資料。Gets or sets the SQL string that the SqlDataSource control uses to retrieve data from the underlying database.

SelectCommandType SelectCommandType SelectCommandType SelectCommandType

取得或設定值,指出 SelectCommand 屬性中的文字是 SQL 查詢還是預存程序的名稱。Gets or sets a value indicating whether the text in the SelectCommand property is an SQL query or the name of a stored procedure.

SelectParameters SelectParameters SelectParameters SelectParameters

取得參數集合,包含與 SelectCommand 控制項相關聯之 SqlDataSourceView 物件 SqlDataSource 屬性所使用的參數。Gets the parameters collection that contains the parameters that are used by the SelectCommand property from the SqlDataSourceView object that is associated with the SqlDataSource control.

Site Site Site Site

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

(Inherited from Control)
SkinID SkinID SkinID SkinID

取得套用至 DataSourceControl 控制項的面板。Gets the skin to apply to the DataSourceControl control.

(Inherited from DataSourceControl)
SortParameterName SortParameterName SortParameterName SortParameterName

取得或設定預存程序參數的名稱,用於在使用預存程序執行資料擷取時,對擷取的資料進行排序。Gets or sets the name of a stored procedure parameter that is used to sort retrieved data when data retrieval is performed using a stored procedure.

SqlCacheDependency SqlCacheDependency SqlCacheDependency SqlCacheDependency

取得或設定以分號分隔的字串,表示用於 Microsoft SQL Server 快取相依性的資料庫和資料表。Gets or sets a semicolon-delimited string that indicates which databases and tables to use for the Microsoft SQL Server cache dependency.

TemplateControl TemplateControl TemplateControl TemplateControl

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

(Inherited from Control)
TemplateSourceDirectory TemplateSourceDirectory TemplateSourceDirectory TemplateSourceDirectory

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

(Inherited from Control)
UniqueID UniqueID UniqueID UniqueID

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

(Inherited from Control)
UpdateCommand UpdateCommand UpdateCommand UpdateCommand

取得或設定 SQL 字串,SqlDataSource 控制項會用來更新基礎資料庫的資料。Gets or sets the SQL string that the SqlDataSource control uses to update data in the underlying database.

UpdateCommandType UpdateCommandType UpdateCommandType UpdateCommandType

取得或設定值,指出 UpdateCommand 屬性中的文字是 SQL 陳述式還是預存程序的名稱。Gets or sets a value indicating whether the text in the UpdateCommand property is an SQL statement or the name of a stored procedure.

UpdateParameters UpdateParameters UpdateParameters UpdateParameters

取得參數集合,包含與 UpdateCommand 控制項相關聯之 SqlDataSourceView 控制項 SqlDataSource 屬性所使用的參數。Gets the parameters collection that contains the parameters that are used by the UpdateCommand property from the SqlDataSourceView control that is associated with the SqlDataSource control.

ValidateRequestMode ValidateRequestMode ValidateRequestMode ValidateRequestMode

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

(Inherited from Control)
ViewState ViewState ViewState 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.

(Inherited from Control)
ViewStateIgnoresCase ViewStateIgnoresCase ViewStateIgnoresCase ViewStateIgnoresCase

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

(Inherited from Control)
ViewStateMode ViewStateMode ViewStateMode ViewStateMode

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

(Inherited from Control)
Visible Visible Visible Visible

取得或設定值,指出是否視覺化顯示控制項。Gets or sets a value indicating whether the control is visually displayed.

(Inherited from DataSourceControl)

方法

AddedControl(Control, Int32) AddedControl(Control, Int32) AddedControl(Control, Int32) AddedControl(Control, Int32)

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

(Inherited from Control)
AddParsedSubObject(Object) AddParsedSubObject(Object) AddParsedSubObject(Object) 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.

(Inherited from Control)
ApplyStyleSheetSkin(Page) ApplyStyleSheetSkin(Page) ApplyStyleSheetSkin(Page) ApplyStyleSheetSkin(Page)

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

(Inherited from DataSourceControl)
BeginRenderTracing(TextWriter, Object) BeginRenderTracing(TextWriter, Object) BeginRenderTracing(TextWriter, Object) BeginRenderTracing(TextWriter, Object)

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

(Inherited from Control)
BuildProfileTree(String, Boolean) BuildProfileTree(String, Boolean) BuildProfileTree(String, Boolean) 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.

(Inherited from Control)
ClearCachedClientID() ClearCachedClientID() ClearCachedClientID() ClearCachedClientID()

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

(Inherited from Control)
ClearChildControlState() ClearChildControlState() ClearChildControlState() ClearChildControlState()

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

(Inherited from Control)
ClearChildState() ClearChildState() ClearChildState() ClearChildState()

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

(Inherited from Control)
ClearChildViewState() ClearChildViewState() ClearChildViewState() ClearChildViewState()

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

(Inherited from Control)
ClearEffectiveClientIDMode() ClearEffectiveClientIDMode() ClearEffectiveClientIDMode() ClearEffectiveClientIDMode()

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

(Inherited from Control)
CreateChildControls() CreateChildControls() CreateChildControls() CreateChildControls()

由 ASP.NET 網頁架構呼叫,通知使用組合實作的伺服器控制項來建立所包含的任何子控制項,以準備回傳或呈現。Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.

(Inherited from Control)
CreateControlCollection() CreateControlCollection() CreateControlCollection() CreateControlCollection()

建立儲存子控制項的集合。Creates a collection to store child controls.

(Inherited from DataSourceControl)
CreateDataSourceView(String) CreateDataSourceView(String) CreateDataSourceView(String) CreateDataSourceView(String)

建立與資料來源控制項相關聯的資料來源檢視物件。Creates a data source view object that is associated with the data source control.

DataBind() DataBind() DataBind() DataBind()

將資料來源繫結至叫用的伺服器控制項和它的全部子控制項。Binds a data source to the invoked server control and all its child controls.

(Inherited from Control)
DataBind(Boolean) DataBind(Boolean) DataBind(Boolean) 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.

(Inherited from Control)
DataBindChildren() DataBindChildren() DataBindChildren() DataBindChildren()

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

(Inherited from Control)
Delete() Delete() Delete() Delete()

使用 DeleteCommand SQL 字串和 DeleteParameters 集合中的任何參數,執行刪除作業。Performs a delete operation using the DeleteCommand SQL string and any parameters that are in the DeleteParameters collection.

Dispose() Dispose() Dispose() Dispose()

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

(Inherited from Control)
EndRenderTracing(TextWriter, Object) EndRenderTracing(TextWriter, Object) EndRenderTracing(TextWriter, Object) EndRenderTracing(TextWriter, Object)

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

(Inherited from Control)
EnsureChildControls() EnsureChildControls() EnsureChildControls() EnsureChildControls()

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

(Inherited from Control)
EnsureID() EnsureID() EnsureID() EnsureID()

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

(Inherited from Control)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
FindControl(String) FindControl(String) FindControl(String) FindControl(String)

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

(Inherited from DataSourceControl)
FindControl(String, Int32) FindControl(String, Int32) FindControl(String, Int32) 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.

(Inherited from Control)
Focus() Focus() Focus() Focus()

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

(Inherited from DataSourceControl)
GetDbProviderFactory() GetDbProviderFactory() GetDbProviderFactory() GetDbProviderFactory()

傳回與 DbProviderFactory 屬性所識別之 ADO.NET 提供者相關聯的 ProviderName 物件。Returns the DbProviderFactory object that is associated with the ADO.NET provider that is identified by the ProviderName property.

GetDesignModeState() GetDesignModeState() GetDesignModeState() GetDesignModeState()

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

(Inherited from Control)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetRouteUrl(Object) GetRouteUrl(Object) GetRouteUrl(Object) GetRouteUrl(Object)

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

(Inherited from Control)
GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary) GetRouteUrl(RouteValueDictionary)

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

(Inherited from Control)
GetRouteUrl(String, Object) GetRouteUrl(String, Object) GetRouteUrl(String, Object) GetRouteUrl(String, Object)

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

(Inherited from Control)
GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary) GetRouteUrl(String, RouteValueDictionary)

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

(Inherited from Control)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
GetUniqueIDRelativeTo(Control) GetUniqueIDRelativeTo(Control) GetUniqueIDRelativeTo(Control) GetUniqueIDRelativeTo(Control)

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

(Inherited from Control)
GetView(String) GetView(String) GetView(String) GetView(String)

取得與資料來源控制項相關聯的具名資料來源檢視。Gets the named data source view that is associated with the data source control.

GetViewNames() GetViewNames() GetViewNames() GetViewNames()

取得名稱集合,表示與 SqlDataSource 控制項相關聯的檢視物件清單。Gets a collection of names representing the list of view objects that are associated with the SqlDataSource control.

HasControls() HasControls() HasControls() HasControls()

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

(Inherited from DataSourceControl)
HasEvents() HasEvents() HasEvents() HasEvents()

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

(Inherited from Control)
Insert() Insert() Insert() Insert()

使用 InsertCommand SQL 字串和 InsertParameters 集合中的任何參數,執行插入作業。Performs an insert operation using the InsertCommand SQL string and any parameters that are in the InsertParameters collection.

IsLiteralContent() IsLiteralContent() IsLiteralContent() IsLiteralContent()

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

(Inherited from Control)
LoadControlState(Object) LoadControlState(Object) LoadControlState(Object) LoadControlState(Object)

SaveControlState() 方法所儲存的上一頁要求中,還原控制項狀態資訊。Restores control-state information from a previous page request that was saved by the SaveControlState() method.

(Inherited from Control)
LoadViewState(Object) LoadViewState(Object) LoadViewState(Object) LoadViewState(Object)

載入 SqlDataSource 控制項中需要保存的屬性狀態。Loads the state of the properties in the SqlDataSource control that need to be persisted.

MapPathSecure(String) MapPathSecure(String) MapPathSecure(String) MapPathSecure(String)

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

(Inherited from Control)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
OnBubbleEvent(Object, EventArgs) OnBubbleEvent(Object, EventArgs) OnBubbleEvent(Object, EventArgs) OnBubbleEvent(Object, EventArgs)

決定伺服器控制項的事件是否要在頁面的 UI 伺服器控制項階層架構中向上傳遞。Determines whether the event for the server control is passed up the page's UI server control hierarchy.

(Inherited from Control)
OnDataBinding(EventArgs) OnDataBinding(EventArgs) OnDataBinding(EventArgs) OnDataBinding(EventArgs)

引發 DataBinding 事件。Raises the DataBinding event.

(Inherited from Control)
OnInit(EventArgs) OnInit(EventArgs) OnInit(EventArgs) OnInit(EventArgs)

LoadComplete 事件處理常式加入包含 Page 控制項的 SqlDataSource 控制項。Adds a LoadComplete event handler to the Page control that contains the SqlDataSource control.

OnLoad(EventArgs) OnLoad(EventArgs) OnLoad(EventArgs) OnLoad(EventArgs)

引發 Load 事件。Raises the Load event.

(Inherited from Control)
OnPreRender(EventArgs) OnPreRender(EventArgs) OnPreRender(EventArgs) OnPreRender(EventArgs)

引發 PreRender 事件。Raises the PreRender event.

(Inherited from Control)
OnUnload(EventArgs) OnUnload(EventArgs) OnUnload(EventArgs) OnUnload(EventArgs)

引發 Unload 事件。Raises the Unload event.

(Inherited from Control)
OpenFile(String) OpenFile(String) OpenFile(String) OpenFile(String)

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

(Inherited from Control)
RaiseBubbleEvent(Object, EventArgs) RaiseBubbleEvent(Object, EventArgs) RaiseBubbleEvent(Object, EventArgs) RaiseBubbleEvent(Object, EventArgs)

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

(Inherited from Control)
RaiseDataSourceChangedEvent(EventArgs) RaiseDataSourceChangedEvent(EventArgs) RaiseDataSourceChangedEvent(EventArgs) RaiseDataSourceChangedEvent(EventArgs)

引發 DataSourceChanged 事件。Raises the DataSourceChanged event.

(Inherited from DataSourceControl)
RemovedControl(Control) RemovedControl(Control) RemovedControl(Control) RemovedControl(Control)

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

(Inherited from Control)
Render(HtmlTextWriter) Render(HtmlTextWriter) Render(HtmlTextWriter) Render(HtmlTextWriter)

將伺服器控制項內容傳送到提供的 HtmlTextWriter 物件,以寫入要在用戶端上呈現的內容。Sends server control content to a provided HtmlTextWriter object, which writes the content to be rendered on the client.

(Inherited from Control)
RenderChildren(HtmlTextWriter) RenderChildren(HtmlTextWriter) RenderChildren(HtmlTextWriter) 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.

(Inherited from Control)
RenderControl(HtmlTextWriter) RenderControl(HtmlTextWriter) RenderControl(HtmlTextWriter) RenderControl(HtmlTextWriter)

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

(Inherited from DataSourceControl)
RenderControl(HtmlTextWriter, ControlAdapter) RenderControl(HtmlTextWriter, ControlAdapter) RenderControl(HtmlTextWriter, ControlAdapter) RenderControl(HtmlTextWriter, ControlAdapter)

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

(Inherited from Control)
ResolveAdapter() ResolveAdapter() ResolveAdapter() ResolveAdapter()

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

(Inherited from Control)
ResolveClientUrl(String) ResolveClientUrl(String) ResolveClientUrl(String) ResolveClientUrl(String)

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

(Inherited from Control)
ResolveUrl(String) ResolveUrl(String) ResolveUrl(String) ResolveUrl(String)

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

(Inherited from Control)
SaveControlState() SaveControlState() SaveControlState() SaveControlState()

儲存頁面回傳至伺服器以來,所發生的任何伺服器控制項狀態變更。Saves any server control state changes that have occurred since the time the page was posted back to the server.

(Inherited from Control)
SaveViewState() SaveViewState() SaveViewState() SaveViewState()

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

Select(DataSourceSelectArguments) Select(DataSourceSelectArguments) Select(DataSourceSelectArguments) Select(DataSourceSelectArguments)

使用 SelectCommand SQL 字串和 SelectParameters 集合中的任何參數,從基礎資料庫擷取資料。Retrieves data from the underlying database by using the SelectCommand SQL string and any parameters that are in the SelectParameters collection.

SetDesignModeState(IDictionary) SetDesignModeState(IDictionary) SetDesignModeState(IDictionary) SetDesignModeState(IDictionary)

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

(Inherited from Control)
SetRenderMethodDelegate(RenderMethod) SetRenderMethodDelegate(RenderMethod) SetRenderMethodDelegate(RenderMethod) SetRenderMethodDelegate(RenderMethod)

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

(Inherited from Control)
SetTraceData(Object, Object) SetTraceData(Object, Object) SetTraceData(Object, Object) SetTraceData(Object, Object)

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

(Inherited from Control)
SetTraceData(Object, Object, Object) SetTraceData(Object, Object, Object) SetTraceData(Object, Object, Object) 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.

(Inherited from Control)
ToString() ToString() ToString() ToString()

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

(Inherited from Object)
TrackViewState() TrackViewState() TrackViewState() TrackViewState()

追蹤 SqlDataSource 控制項的檢視狀態變更,以便變更可以儲存在控制項的 StateBag 物件中。Tracks view state changes to the SqlDataSource control so that the changes can be stored in the StateBag object for the control.

Update() Update() Update() Update()

使用 UpdateCommand SQL 字串和 UpdateParameters 集合中的任何參數,執行更新作業。Performs an update operation using the UpdateCommand SQL string and any parameters that are in the UpdateParameters collection.

事件

DataBinding DataBinding DataBinding DataBinding

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

(Inherited from Control)
Deleted Deleted Deleted Deleted

發生於刪除作業已經完成時。Occurs when a delete operation has completed.

Deleting Deleting Deleting Deleting

在刪除作業之前發生。Occurs before a delete operation.

Disposed Disposed Disposed 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.

(Inherited from Control)
Filtering Filtering Filtering Filtering

在篩選作業之前發生。Occurs before a filter operation.

IDataSource.DataSourceChanged IDataSource.DataSourceChanged IDataSource.DataSourceChanged IDataSource.DataSourceChanged

當資料來源控制項變更的方式會影響資料繫結控制項時發生。Occurs when a data source control has changed in a way that affects data-bound controls.

(Inherited from DataSourceControl)
Init Init Init Init

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

(Inherited from Control)
Inserted Inserted Inserted Inserted

發生於插入作業已經完成時。Occurs when an insert operation has completed.

Inserting Inserting Inserting Inserting

在插入作業之前發生。Occurs before an insert operation.

Load Load Load Load

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

(Inherited from Control)
PreRender PreRender PreRender PreRender

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

(Inherited from Control)
Selected Selected Selected Selected

發生於資料擷取作業已經完成時。Occurs when a data retrieval operation has completed.

Selecting Selecting Selecting Selecting

在資料擷取作業之前發生。Occurs before a data retrieval operation.

Unload Unload Unload Unload

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

(Inherited from Control)
Updated Updated Updated Updated

發生於更新作業已經完成時。Occurs when an update operation has completed.

Updating Updating Updating Updating

在更新作業之前發生。Occurs before an update operation.

明確介面實作

IControlDesignerAccessor.GetDesignModeState() IControlDesignerAccessor.GetDesignModeState() IControlDesignerAccessor.GetDesignModeState() IControlDesignerAccessor.GetDesignModeState()

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

(Inherited from Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary) IControlDesignerAccessor.SetDesignModeState(IDictionary) IControlDesignerAccessor.SetDesignModeState(IDictionary) IControlDesignerAccessor.SetDesignModeState(IDictionary)

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

(Inherited from Control)
IControlDesignerAccessor.SetOwnerControl(Control) IControlDesignerAccessor.SetOwnerControl(Control) IControlDesignerAccessor.SetOwnerControl(Control) IControlDesignerAccessor.SetOwnerControl(Control)

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

(Inherited from Control)
IDataSource.GetView(String) IDataSource.GetView(String) IDataSource.GetView(String) IDataSource.GetView(String)

取得與 DataSourceView 控制項關聯的具名 DataSourceControl 物件。Gets the named DataSourceView object associated with the DataSourceControl control. 有些資料來源控制項只支援一個檢視,有些則可支援多個檢視。Some data source controls support only one view, while others support more than one.

(Inherited from DataSourceControl)
IDataSource.GetViewNames() IDataSource.GetViewNames() IDataSource.GetViewNames() IDataSource.GetViewNames()

取得名稱集合,表示與 DataSourceView 控制項關聯的 DataSourceControl 物件清單。Gets a collection of names, representing the list of DataSourceView objects associated with the DataSourceControl control.

(Inherited from DataSourceControl)
IListSource.GetList() IListSource.GetList() IListSource.GetList() IListSource.GetList()

取得可以當做資料清單來源使用的資料來源控制項清單。Gets a list of data source controls that can be used as sources of lists of data.

(Inherited from DataSourceControl)
IParserAccessor.AddParsedSubObject(Object) IParserAccessor.AddParsedSubObject(Object) IParserAccessor.AddParsedSubObject(Object) IParserAccessor.AddParsedSubObject(Object)

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

(Inherited from Control)

擴充方法

FindDataSourceControl(Control) FindDataSourceControl(Control) FindDataSourceControl(Control) FindDataSourceControl(Control)

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

FindFieldTemplate(Control, String) FindFieldTemplate(Control, String) FindFieldTemplate(Control, String) FindFieldTemplate(Control, String)

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

FindMetaTable(Control) FindMetaTable(Control) FindMetaTable(Control) FindMetaTable(Control)

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

GetDefaultValues(IDataSource) GetDefaultValues(IDataSource) GetDefaultValues(IDataSource) GetDefaultValues(IDataSource)

取得所指定資料來源的預設值集合。Gets the collection of the default values for the specified data source.

GetMetaTable(IDataSource) GetMetaTable(IDataSource) GetMetaTable(IDataSource) GetMetaTable(IDataSource)

取得所指定資料來源物件中的資料表中繼資料。Gets the metadata for a table in the specified data source object.

TryGetMetaTable(IDataSource, MetaTable) TryGetMetaTable(IDataSource, MetaTable) TryGetMetaTable(IDataSource, MetaTable) TryGetMetaTable(IDataSource, MetaTable)

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

適用於

另請參閱