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:

  • 第一个代码示例演示如何显示数据从 SQL Server 中GridView控制使用声明性语法。The first code example demonstrates how to display data from SQL Server in a GridView control using declarative syntax.

  • 第二个代码示例演示如何显示从符合 ODBC 的数据库中的数据GridView控制使用声明性语法。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. ProviderName属性是用于 ODBC,这是.NET Framework 数据提供程序名称System.Data.OdbcThe 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. GridView控件自动处理添加到参数UpdateParameters集合并调用Update方法时更新按钮GridView单击控件。The 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. DropDownList控件不会自动添加到更新参数UpdateParameters集合,也不调用Update方法,因此必须这样做。The 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 网页验证用户输入是否不包含脚本或 HTML 元素。By default, ASP.NET Web pages validate that user input does not include script or HTML elements. 有关详细信息,请参阅脚本侵入概述For more information, see Script Exploits Overview.

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

<script runat="server">
 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. SqlDataSource可以支持可连接到使用 ADO.NET 提供程序,例如任何 SQL 关系数据库SqlClientOleDbOdbc,或OracleClient提供程序。The 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. 有关如何保护连接字符串的信息,请参阅How To:安全连接字符串的使用数据源控件时For information about how to secure connection strings, see How To: Secure Connection Strings when Using Data Source Controls.

若要从基础数据库检索数据,设置SelectCommandSQL 查询的属性。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控件中检索数据时Select调用方法。The 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. Select绑定到控件自动调用方法SqlDataSource时其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. 设置DataSourceID属性是绑定的建议的方法ObjectDataSource数据绑定控件的控件。Setting 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. 可以使用的数据绑定控件的一些示例SqlDataSourceDataGridDetailsViewDataList,和DropDownListSome 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的数据绑定控件绑定到的 ID 属性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.

SQL 查询和命令中使用SelectCommandUpdateCommandInsertCommand,和DeleteCommand可以参数化属性。The 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 窗体页的查询字符串传递的值、 其他服务器控件和的详细信息的属性值。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属性设置为falseYou can change this behavior by setting the CancelSelectOnNullParameter property to false.

数据提供程序Data Provider

默认情况下SqlDataSource控制.NET Framework 数据提供程序与 SQL Server 配合工作,但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. SqlDataSource会自动调整缓存数据时EnableCaching属性设置为trueCacheDuration属性设置为在缓存中存储数据的缓存项将被丢弃之前的秒数。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 设置DataSourceMode属性设置为DataSet值,EnableCaching属性设置为true,并CacheDurationCacheExpirationPolicy根据缓存数据所需的缓存行为的属性。Set 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.
正在删除Deleting 设置DeleteCommand属性设置为用于删除数据的 SQL 语句。Set the DeleteCommand property to an SQL statement used to delete data. 此语句通常已参数化。This statement is typically parameterized.
筛选Filtering 设置DataSourceMode属性设置为DataSet值。Set the DataSourceMode property to the DataSet value. 设置FilterExpression属性设置为用来筛选数据的筛选表达式时Select调用方法。Set 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,设置时,支持分页DataSourceMode属性设置为DataSet值。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控件所关联的数据源视图类。As with all data source controls, the SqlDataSource control is associated with a data source view class. SqlDataSource控件仅有一个关联SqlDataSourceView,并且始终名为TableThe 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

获取或设置 SqlDataSource 控件从基础数据库删除数据所用的 SQL 字符串。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

获取控件的事件处理程序委托列表。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

获取或设置 SqlDataSource 控件将数据插入基础数据库所用的 SQL 字符串。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

获取对页 UI 层次结构中服务器控件的父控件的引用。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

获取或设置 SqlDataSource 控件从基础数据库检索数据所用的 SQL 字符串。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

获取或设置 SqlDataSource 控件更新基础数据库中的数据所用的 SQL 字符串。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)

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

(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。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。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 的浅表副本。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)

获取与 DataSourceControl 控件关联的指定 DataSourceView 对象。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()

获取名称的集合,表示与 DataSourceControl 控件关联的 DataSourceView 对象的列表。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.

适用于

另请参阅