SqlDataSource 类

定义

表示数据绑定控件的 SQL 数据库。

public ref class SqlDataSource : System::Web::UI::DataSourceControl
[System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.SqlDataSource))]
public class SqlDataSource : System.Web.UI.DataSourceControl
[<System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.SqlDataSource))>]
type SqlDataSource = class
    inherit DataSourceControl
Public Class SqlDataSource
Inherits DataSourceControl
继承
派生
属性

示例

本部分包含四个代码示例:

  • 第一个GridView代码示例演示如何使用声明性语法在 控件中显示SQL Server中的数据。

  • 第二个 GridView 代码示例演示如何使用声明性语法在控件中显示 ODBC 兼容数据库中的数据。

  • 第三个 GridView 代码示例演示如何在 控件中显示和更新数据。

  • 第四个 DropDownList 代码示例演示如何在 控件中显示和更新数据。

    注意

    这些示例演示如何使用声明性语法进行数据访问。 有关如何使用代码而不是标记访问数据的信息,请参阅 在 Visual Studio 中访问数据

下面的代码示例演示如何以声明方式使用 SqlDataSource 控件从SQL Server检索数据并将其显示在 控件中GridView

<%@ 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 。 属性ProviderName是 ODBC .NET Framework数据提供程序的名称,即 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 。 与前面的示例一样,来自 Northwind 数据库的数据显示在 控件中 GridView 。 此外,由于指定了 UpdateCommand 属性,并且属性 AutoGenerateEditButton 设置为 true,因此无需其他代码即可编辑和更新记录。 控件GridView会自动处理向UpdateParameters集合添加参数,并在单击控件中的GridView更新”按钮时调用 Update 方法。

<%@ 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 控件的常见显示和更新方案。 控件 DropDownList 不会自动将更新参数添加到集合中 UpdateParameters ,也不会调用 Update 方法,因此必须执行此操作。 更新参数以声明方式指定,可以添加事件处理程序,以在引发事件时执行 Update 操作。

重要

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

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

<script runat="server">
 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>

注解

本主题内容:

介绍

SqlDataSource数据源控件将 SQL 关系数据库中的数据表示为数据绑定控件。 可以将 控件 SqlDataSource 与数据绑定控件结合使用,从关系数据库中检索数据,并在网页上显示、编辑和排序数据,且代码很少或没有代码。

数据连接

若要连接到数据库,必须将 属性设置为 ConnectionString 有效的连接字符串。 可以 SqlDataSource 支持可以使用 ADO.NET 提供程序(例如 SqlClientOleDbOdbcOracleClient 提供程序)连接到的任何 SQL 关系数据库。 有关如何保护连接字符串的信息,请参阅 如何:在使用数据源控件时保护连接字符串

若要从基础数据库检索数据,请使用 SQL 查询设置 SelectCommand 属性。 如果与 关联的数据库 SqlDataSource 支持存储过程,则可以将 SelectCommand 属性设置为存储过程的名称。 指定的 SQL 查询也可以是参数化查询。 可以将与参数化查询关联的对象添加到Parameter集合。SelectParameters 有关参数化 SQL 查询及其语法的详细信息,请参阅 将参数与数据源控件配合使用进行筛选

每当调用 方法时, 控件 SqlDataSourceSelect 检索数据。 此方法提供对属性指定的方法的 SelectMethod 编程访问。 调用 Select 方法时,由绑定到 SqlDataSource 的控件自动调用方法 DataBind 。 如果设置 DataSourceID 数据绑定控件的 属性,则控件会根据需要自动绑定到数据源中的数据。 DataSourceID设置 属性是将控件绑定到ObjectDataSource数据绑定控件的推荐方法。 或者,可以使用 DataSource 属性,但必须显式调用 DataBind 数据绑定控件的 方法。 可以使用 SqlDataSource 的数据绑定控件的一些示例包括 DataGridDetailsViewDataListDropDownList。 可以随时以编程方式调用 Select 方法,以从基础数据库检索数据。

在声明性和编程 ASP.NET 方案中,可以将数据绑定控件的 属性设置为 DataSourceID 控件的 SqlDataSource ID。 还可以将 类的 SqlDataSource 实例分配给 DataSource 数据绑定控件的 属性。 有关将数据绑定控件绑定到数据源控件的详细信息,请参阅 ASP.NET 数据访问选项

执行数据操作

根据基础数据库产品的功能和 类实例 SqlDataSource 的配置,可以执行更新、插入和删除等数据操作。 若要执行这些数据操作,请为要执行的操作设置相应的命令文本和任何关联的参数。 例如,对于更新操作,将 UpdateCommand 属性设置为 SQL 字符串或存储过程的名称,并将任何必需的参数添加到集合中 UpdateParameters 。 更新是在由代码显式调用或由数据绑定控件自动调用 方法时 Update 执行的。 和 Insert 操作遵循Delete相同的常规模式。

可以在 、UpdateCommandInsertCommand和 属性中使用的 SelectCommandSQL 查询和DeleteCommand命令进行参数化。 这意味着查询或命令可以使用占位符而不是文本值,并将占位符绑定到应用程序或用户定义的变量。 可以将 SQL 查询中的参数绑定到会话变量、Web Forms页的查询字符串上传递的值、其他服务器控件的属性值等。 有关如何通过 在 SQL 查询 SqlDataSource中使用参数的详细信息,请参阅 将参数与数据源控件配合使用进行筛选对 SqlDataSource 控件使用参数

注意

默认情况下,如果其中一个参数是 null 执行 Select 命令时,则不会返回任何数据,也不会引发异常。 可以通过将 属性设置为 CancelSelectOnNullParameterfalse来更改此行为。

数据提供程序

默认情况下,该SqlDataSource控件适用于 SQL Server .NET Framework 数据提供程序,但SqlDataSource不是特定于 Microsoft SQL Server。 可以将控件与具有托管 ADO.NET 提供程序的任何数据库产品连接 SqlDataSource 。 与提供程序一起使用 System.Data.OleDb 时, SqlDataSource 可以与任何符合 OLE DB 的数据库一起使用。 与提供程序一 System.Data.Odbc 起使用时, SqlDataSource 可以与任何 ODBC 驱动程序和数据库(包括 IBM DB2、MySQL 和 PostgreSQL)一起使用。 与 提供程序一起使用 System.Data.OracleClient 时, SqlDataSource 可以与 Oracle 8.1.7 数据库及更高版本配合使用。 允许的提供程序列表在 DbProviderFactories 配置文件的 部分(Machine.config或Web.config文件)中注册。 有关详细信息,请参阅 使用 SqlDataSource 控件选择数据

缓存

如果使用 控件在页面上 SqlDataSource 显示数据,则可以通过使用数据源控件的数据缓存功能来提高页面的性能。 缓存会降低数据库服务器上的处理负载,但代价是 Web 服务器上的内存;在大多数情况下,这是一个很好的权衡。 SqlDataSourceEnableCaching 属性设置为 true 时,会自动缓存数据,CacheDuration并将 属性设置为缓存在放弃缓存条目之前存储数据的秒数。 还可以指定 CacheExpirationPolicy 和 可选 SqlCacheDependency 值。

其他功能

SqlDataSource提供了其他功能,如下表所示。

功能 要求
缓存 根据DataSourceMode缓存数据所需的缓存行为,将 属性DataSet设置为 trueEnableCaching,将 属性设置为 和 CacheDurationCacheExpirationPolicy 属性。
正在删除 DeleteCommand 属性设置为用于删除数据的 SQL 语句。 此语句通常参数化。
Filtering DataSourceMode 属性设置为 DataSet 值。 将 FilterExpression 属性设置为在调用 方法时 Select 用于筛选数据的筛选表达式。
插入 InsertCommand 属性设置为用于插入数据的 SQL 语句。 此语句通常参数化。
分页 当前不支持 SqlDataSource,但是,将 属性设置为DataSourceModeDataSet值时,某些数据绑定控件(如 GridView)支持分页。
选择 SelectCommand 属性设置为用于检索数据的 SQL 语句。
排序 DataSourceMode 属性设置为 DataSet
更新 UpdateCommand 属性设置为用于更新数据的 SQL 语句。 此语句通常参数化。

“数据源视图”

与所有数据源控件一样,控件 SqlDataSource 与数据源视图类相关联。 控件 SqlDataSource 只有一个关联的 SqlDataSourceView,并且它始终名为 Table

控件没有可视化呈现 SqlDataSource ;它是作为控件实现的,以便你可以以声明方式创建它,还可以选择允许它参与状态管理。 因此, SqlDataSource 不支持视觉功能,例如 由 EnableThemingSkinID 属性提供的视觉功能。

声明性语法

<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(String, String)

使用指定的连接字符串和 Select 命令初始化 SqlDataSource 类的新实例。

SqlDataSource(String, String, String)

使用指定的连接字符串和 Select 命令初始化 SqlDataSource 类的新实例。

属性

Adapter

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

(继承自 Control)
AppRelativeTemplateSourceDirectory

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

(继承自 Control)
BindingContainer

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

(继承自 Control)
CacheDuration

获取或设置以秒为单位的一段时间,它是数据源控件缓存 Select(DataSourceSelectArguments) 方法所检索到的数据的时间。

CacheExpirationPolicy

获取或设置缓存的到期行为,该行为与持续时间组合在一起可以描述数据源控件所用缓存的行为。

CacheKeyDependency

获取或设置一个用户定义的键依赖项,该键依赖项链接到数据源控件创建的所有数据缓存对象。 当键到期时,所有缓存对象都显式到期。

CancelSelectOnNullParameter

获取或设置一个值,该值指示当 SelectParameters 集合中包含的任何一个参数为 null 时,是否取消数据检索操作。

ChildControlsCreated

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

(继承自 Control)
ClientID

获取由 ASP.NET 生成的服务器控件标识符。

(继承自 DataSourceControl)
ClientIDMode

此属性不用于数据源控件。

(继承自 DataSourceControl)
ClientIDSeparator

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

(继承自 Control)
ConflictDetection

获取或设置值,该值指示操作期间基础数据库中的一行数据更改时,SqlDataSource 控件如何执行更新和删除。

ConnectionString

获取或设置特定于 ADO.NET 提供程序的连接字符串,SqlDataSource 控件使用该字符串连接基础数据库。

Context

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

(继承自 Control)
Controls

获取 ControlCollection 对象,该对象表示 UI 层次结构中的指定服务器控件的子控件。

(继承自 DataSourceControl)
DataItemContainer

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

(继承自 Control)
DataKeysContainer

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

(继承自 Control)
DataSourceMode

获取或设置 SqlDataSource 控件获取数据所用的数据检索模式。

DeleteCommand

获取或设置 SqlDataSource 控件从基础数据库删除数据所用的 SQL 字符串。

DeleteCommandType

获取或设置一个值,该值指示 DeleteCommand 属性中的文本是 SQL 语句还是存储过程的名称。

DeleteParameters

从与 DeleteCommand 控件相关联的 SqlDataSourceView 对象获取包含 SqlDataSource 属性所使用的参数的参数集合。

DesignMode

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

(继承自 Control)
EnableCaching

获取或设置一个值,该值指示 SqlDataSource 控件是否启用数据缓存。

EnableTheming

获取一个值,该值指示此控件是否支持主题。

(继承自 DataSourceControl)
EnableViewState

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

(继承自 Control)
Events

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

(继承自 Control)
FilterExpression

获取或设置调用 Select(DataSourceSelectArguments) 方法时应用的筛选表达式。

FilterParameters

获取与 FilterExpression 字符串中的任何参数占位符关联的参数的集合。

HasChildViewState

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

(继承自 Control)
ID

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

(继承自 Control)
IdSeparator

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

(继承自 Control)
InsertCommand

获取或设置 SqlDataSource 控件将数据插入基础数据库所用的 SQL 字符串。

InsertCommandType

获取或设置一个值,该值指示 InsertCommand 属性中的文本是 SQL 语句还是存储过程的名称。

InsertParameters

从与 InsertCommand 控件相关联的 SqlDataSourceView 对象获取包含 SqlDataSource 属性所使用的参数的参数集合。

IsChildControlStateCleared

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

(继承自 Control)
IsTrackingViewState

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

(继承自 Control)
IsViewStateEnabled

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

(继承自 Control)
LoadViewStateByID

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

(继承自 Control)
NamingContainer

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

(继承自 Control)
OldValuesParameterFormatString

获取或设置一个格式字符串,该字符串应用于传递给 Delete()Update() 方法的所有参数的名称。

Page

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

(继承自 Control)
Parent

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

(继承自 Control)
ProviderName

获取或设置 .NET Framework 数据提供程序的名称,SqlDataSource 控件使用该提供程序来连接基础数据源。

RenderingCompatibility

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

(继承自 Control)
SelectCommand

获取或设置 SqlDataSource 控件从基础数据库检索数据所用的 SQL 字符串。

SelectCommandType

获取或设置一个值,该值指示 SelectCommand 属性中的文本是 SQL 查询还是存储过程的名称。

SelectParameters

从与 SelectCommand 控件相关联的 SqlDataSourceView 对象获取包含 SqlDataSource 属性所使用的参数的参数集合。

Site

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

(继承自 Control)
SkinID

获取要应用于 DataSourceControl 控件的外观。

(继承自 DataSourceControl)
SortParameterName

获取或设置存储过程参数的名称,在使用存储过程执行数据检索时,该存储过程参数用于对检索到的数据进行排序。

SqlCacheDependency

获取或设置一个用分号分隔的字符串,指示用于 Microsoft SQL Server 缓存依赖项的数据库和表。

TemplateControl

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

(继承自 Control)
TemplateSourceDirectory

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

(继承自 Control)
UniqueID

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

(继承自 Control)
UpdateCommand

获取或设置 SqlDataSource 控件更新基础数据库中的数据所用的 SQL 字符串。

UpdateCommandType

获取或设置一个值,该值指示 UpdateCommand 属性中的文本是 SQL 语句还是存储过程的名称。

UpdateParameters

从与 UpdateCommand 控件相关联的 SqlDataSourceView 控件获取包含 SqlDataSource 属性所使用的参数的参数集合。

ValidateRequestMode

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

(继承自 Control)
ViewState

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

(继承自 Control)
ViewStateIgnoresCase

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

(继承自 Control)
ViewStateMode

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

(继承自 Control)
Visible

获取或设置一个值,该值指示是否以可视化方式显示控件。

(继承自 DataSourceControl)

方法

AddedControl(Control, Int32)

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

(继承自 Control)
AddParsedSubObject(Object)

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

(继承自 Control)
ApplyStyleSheetSkin(Page)

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

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

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

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

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

(继承自 Control)
ClearCachedClientID()

将缓存的 ClientID 值设置为 null

(继承自 Control)
ClearChildControlState()

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

(继承自 Control)
ClearChildState()

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

(继承自 Control)
ClearChildViewState()

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

(继承自 Control)
ClearEffectiveClientIDMode()

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

(继承自 Control)
CreateChildControls()

由 ASP.NET 页框架调用,以通知服务器控件在准备回发或呈现时使用基于撰写的实现来创建其所包含任何子控件。

(继承自 Control)
CreateControlCollection()

创建用于存储子控件的集合。

(继承自 DataSourceControl)
CreateDataSourceView(String)

创建与数据源控件关联的数据源视图对象。

DataBind()

将数据源绑定到调用的服务器控件及其所有子控件。

(继承自 Control)
DataBind(Boolean)

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

(继承自 Control)
DataBindChildren()

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

(继承自 Control)
Delete()

使用 DeleteCommand SQL 字符串和 DeleteParameters 集合中的所有参数执行删除操作。

Dispose()

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

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

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

(继承自 Control)
EnsureChildControls()

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

(继承自 Control)
EnsureID()

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

(继承自 Control)
Equals(Object)

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

(继承自 Object)
FindControl(String)

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

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

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

(继承自 Control)
Focus()

为控件设置输入焦点。

(继承自 DataSourceControl)
GetDbProviderFactory()

返回与 DbProviderFactory 属性所标识的 ADO.NET 提供程序相关联的 ProviderName 对象。

GetDesignModeState()

获取控件的设计时数据。

(继承自 Control)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetRouteUrl(Object)

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

(继承自 Control)
GetRouteUrl(RouteValueDictionary)

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

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

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

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

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

(继承自 Control)
GetType()

获取当前实例的 Type

(继承自 Object)
GetUniqueIDRelativeTo(Control)

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

(继承自 Control)
GetView(String)

获取与数据源控件关联的命名的数据源视图。

GetViewNames()

获取名称的集合,这些名称表示与 SqlDataSource 控件关联的视图对象的列表。

HasControls()

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

(继承自 DataSourceControl)
HasEvents()

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

(继承自 Control)
Insert()

使用 InsertCommand SQL 字符串和 InsertParameters 集合中的所有参数执行插入操作。

IsLiteralContent()

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

(继承自 Control)
LoadControlState(Object)

SaveControlState() 方法保存的上一个页请求还原控件状态信息。

(继承自 Control)
LoadViewState(Object)

加载 SqlDataSource 控件中需要保留的属性的状态。

MapPathSecure(String)

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

(继承自 Control)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
OnBubbleEvent(Object, EventArgs)

确定服务器控件的事件是否沿页的 UI 服务器控件层次结构向上传递。

(继承自 Control)
OnDataBinding(EventArgs)

引发 DataBinding 事件。

(继承自 Control)
OnInit(EventArgs)

LoadComplete 事件处理程序添加到包含 Page 控件的 SqlDataSource 控件中。

OnLoad(EventArgs)

引发 Load 事件。

(继承自 Control)
OnPreRender(EventArgs)

引发 PreRender 事件。

(继承自 Control)
OnUnload(EventArgs)

引发 Unload 事件。

(继承自 Control)
OpenFile(String)

获取用于读取文件的 Stream

(继承自 Control)
RaiseBubbleEvent(Object, EventArgs)

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

(继承自 Control)
RaiseDataSourceChangedEvent(EventArgs)

引发 DataSourceChanged 事件。

(继承自 DataSourceControl)
RemovedControl(Control)

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

(继承自 Control)
Render(HtmlTextWriter)

将服务器控件内容发送到给定的 HtmlTextWriter 对象,该对象可编写将在客户端呈现的内容。

(继承自 Control)
RenderChildren(HtmlTextWriter)

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

(继承自 Control)
RenderControl(HtmlTextWriter)

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

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

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

(继承自 Control)
ResolveAdapter()

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

(继承自 Control)
ResolveClientUrl(String)

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

(继承自 Control)
ResolveUrl(String)

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

(继承自 Control)
SaveControlState()

保存将页面回发到服务器之后发生的所有服务器控件状态更改。

(继承自 Control)
SaveViewState()

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

Select(DataSourceSelectArguments)

通过使用 SelectCommand SQL 字符串以及 SelectParameters 集合中的任何参数,从基础数据库中检索数据。

SetDesignModeState(IDictionary)

为控件设置设计时数据。

(继承自 Control)
SetRenderMethodDelegate(RenderMethod)

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

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

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

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

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

(继承自 Control)
ToString()

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

(继承自 Object)
TrackViewState()

跟踪对 SqlDataSource 控件的视图状态的更改,以便可将这些更改存储在该控件的 StateBag 对象中。

Update()

使用 UpdateCommand SQL 字符串和 UpdateParameters 集合中的所有参数执行更新操作。

事件

DataBinding

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

(继承自 Control)
Deleted

完成删除操作后发生。

Deleting

执行删除操作前发生。

Disposed

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

(继承自 Control)
Filtering

执行筛选操作前发生。

Init

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

(继承自 Control)
Inserted

完成插入操作后发生。

Inserting

执行插入操作前发生。

Load

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

(继承自 Control)
PreRender

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

(继承自 Control)
Selected

数据检索操作完成后发生。

Selecting

执行数据检索操作前发生。

Unload

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

(继承自 Control)
Updated

完成更新操作后发生。

Updating

执行更新操作前发生。

显式接口实现

IControlBuilderAccessor.ControlBuilder

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

(继承自 Control)
IControlDesignerAccessor.GetDesignModeState()

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

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

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

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

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

(继承自 Control)
IControlDesignerAccessor.UserData

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

(继承自 Control)
IDataBindingsAccessor.DataBindings

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

(继承自 Control)
IDataBindingsAccessor.HasDataBindings

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

(继承自 Control)
IDataSource.DataSourceChanged

当数据源控件以某种影响数据绑定控件的方式发生更改时发生。

(继承自 DataSourceControl)
IDataSource.GetView(String)

获取与 DataSourceControl 控件关联的指定 DataSourceView 对象。 有些数据源控件只支持一个视图,有些则支持多个视图。

(继承自 DataSourceControl)
IDataSource.GetViewNames()

获取名称的集合,表示与 DataSourceControl 控件关联的 DataSourceView 对象的列表。

(继承自 DataSourceControl)
IExpressionsAccessor.Expressions

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

(继承自 Control)
IExpressionsAccessor.HasExpressions

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

(继承自 Control)
IListSource.ContainsListCollection

指示数据源控件是否与一个或多个数据列表相关联。

(继承自 DataSourceControl)
IListSource.GetList()

获取可用作数据列表的源的数据源控件列表。

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

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

(继承自 Control)

扩展方法

FindDataSourceControl(Control)

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

FindFieldTemplate(Control, String)

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

FindMetaTable(Control)

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

GetDefaultValues(IDataSource)

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

GetMetaTable(IDataSource)

获取指定数据源对象中表的元数据。

TryGetMetaTable(IDataSource, MetaTable)

确定表元数据是否可用。

适用于

另请参阅