ObjectDataSource 类

定义

表示为多层 Web 应用程序体系结构中的数据绑定控件提供数据的业务对象。

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

示例

本部分显示 ObjectDataSource .aspx 页中的 in 标记,并显示它使用的业务对象。 示例是 .aspx 页。 它包含绑定到 GridView 控件的 ObjectDataSource 控件。 控件 ObjectDataSource 标记指定要为检索数据而调用的业务对象名称和业务对象方法的名称。

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS" Assembly="Samples.AspNet.CS" %>
<%@ 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>
    <title>ObjectDataSource - C# Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">

        <asp:gridview
          id="GridView1"
          runat="server"
          datasourceid="ObjectDataSource1" />

        <asp:objectdatasource
          id="ObjectDataSource1"
          runat="server"
          selectmethod="GetAllEmployees"
          typename="Samples.AspNet.CS.EmployeeLogic" />

    </form>
  </body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB" Assembly="Samples.AspNet.VB" %>
<%@ 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>
    <title>ObjectDataSource - Visual Basic Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">

        <asp:gridview
          id="GridView1"
          runat="server"
          datasourceid="ObjectDataSource1" />

        <asp:objectdatasource
          id="ObjectDataSource1"
          runat="server"
          selectmethod="GetAllEmployees"
          typename="Samples.AspNet.VB.EmployeeLogic" />

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

以下示例演示 .aspx 页中的控件使用的业务对象 ObjectDataSource 。 (许多其他 ObjectDataSource 代码示例也使用此业务对象。) 该示例由以下两个基本类组成:

  • EmployeeLogic 是 使用的业务逻辑类 ObjectDataSource

  • NorthwindEmployee 定义由 GetAllEmployees 类的 方法 EmployeeLogic 返回的数据对象。

为了方便起见,提供了一个附加 NorthwindDataException 类。

这组示例类适用于 Microsoft SQL Server 和 Microsoft Access 提供的 Northwind Traders 数据库。 对于完整的工作示例,必须通过提供的 .aspx 页示例编译并使用这些类。

namespace Samples.AspNet.CS {

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;
  //
  // EmployeeLogic is a stateless business object that encapsulates
  // the operations one can perform on a NorthwindEmployee object.
  //
  public class EmployeeLogic {

    // Returns a collection of NorthwindEmployee objects.
    public static ICollection GetAllEmployees () {
      ArrayList al = new ArrayList();

      ConnectionStringSettings cts = ConfigurationManager.ConnectionStrings["NorthwindConnection"];

      SqlDataSource sds
        = new SqlDataSource(cts.ConnectionString, "SELECT EmployeeID FROM Employees");

      try {

        IEnumerable IDs = sds.Select(DataSourceSelectArguments.Empty);

        // Iterate through the Enumeration and create a
        // NorthwindEmployee object for each ID.
        foreach (DataRowView row in IDs) {
          string id = row["EmployeeID"].ToString();
          NorthwindEmployee nwe = new NorthwindEmployee(id);
          // Add the NorthwindEmployee object to the collection.
          al.Add(nwe);
        }
      }
      finally {
        // If anything strange happens, clean up.
        sds.Dispose();
      }

      return al;
    }
    public static NorthwindEmployee GetEmployee(object anID) {
      return new NorthwindEmployee(anID);
    }

    public static void UpdateEmployeeInfo(NorthwindEmployee ne) {
      bool retval = ne.Save();
      if (! retval) { throw new NorthwindDataException("UpdateEmployee failed."); }
    }

    public static void DeleteEmployee(NorthwindEmployee ne) { }
  }

  public class NorthwindEmployee {

    public NorthwindEmployee () {
      ID = DBNull.Value;
      lastName = "";
      firstName = "";
      title="";
      titleOfCourtesy = "";
      reportsTo = -1;
    }

    public NorthwindEmployee (object anID) {
      this.ID = anID;

      ConnectionStringSettings cts = ConfigurationManager.ConnectionStrings["NorthwindConnection"];

        SqlConnection conn = new SqlConnection (cts.ConnectionString);
      SqlCommand sc =
        new SqlCommand(" SELECT FirstName,LastName,Title,TitleOfCourtesy,ReportsTo " +
                       " FROM Employees " +
                       " WHERE EmployeeID = @empId",
                       conn);
      // Add the employee ID parameter and set its value.
      sc.Parameters.Add(new SqlParameter("@empId",SqlDbType.Int)).Value = Int32.Parse(anID.ToString());
      SqlDataReader sdr = null;

      try {
        conn.Open();
        sdr = sc.ExecuteReader();

        // This is not a while loop. It only loops once.
        if (sdr != null && sdr.Read()) {
          // The IEnumerable contains DataRowView objects.
          this.firstName        = sdr["FirstName"].ToString();
          this.lastName         = sdr["LastName"].ToString();
          this.title            = sdr["Title"].ToString();
          this.titleOfCourtesy  = sdr["TitleOfCourtesy"].ToString();
          if (! sdr.IsDBNull(4)) {
            this.reportsTo        = sdr.GetInt32(4);
          }
        }
        else {
          throw new NorthwindDataException("Data not loaded for employee id.");
        }
      }
      finally {
        try {
          if (sdr != null) sdr.Close();
          conn.Close();
        }
        catch (SqlException) {
          // Log an event in the Application Event Log.
          throw;
        }
      }
    }

    private object ID;

    private string lastName;
    public string LastName {
      get { return lastName; }
      set { lastName = value; }
    }

    private string firstName;
    public string FirstName {
      get { return firstName; }
      set { firstName = value;  }
    }

    private string title;
    public String Title {
      get { return title; }
      set { title = value; }
    }

    private string titleOfCourtesy;
    public string Courtesy {
      get { return titleOfCourtesy; }
      set { titleOfCourtesy = value; }
    }

    private int    reportsTo;
    public int Supervisor {
      get { return reportsTo; }
      set { reportsTo = value; }
    }

    public bool Save () {
      return true;
    }
  }

  internal class NorthwindDataException: Exception {
    public NorthwindDataException(string msg) : base (msg) { }
  }
}
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace Samples.AspNet.VB
'
' EmployeeLogic is a stateless business object that encapsulates
' the operations you can perform on a NorthwindEmployee object.
' When the class is written in Visual Basic, you cannot use the Shared
' part.
Public Class EmployeeLogic
   ' Returns a collection of NorthwindEmployee objects.
   Public Shared Function GetAllEmployees() As ICollection
      Dim al As New ArrayList()

      Dim cts As ConnectionStringSettings = ConfigurationManager.ConnectionStrings("NorthwindConnection")
      Dim sds As New SqlDataSource(cts.ConnectionString, "SELECT EmployeeID FROM Employees")
      Try
         Dim IDs As IEnumerable = sds.Select(DataSourceSelectArguments.Empty)

         ' Iterate through the Enumeration and create a
         ' NorthwindEmployee object for each ID.
         For Each row As DataRowView In IDs
            Dim id As String = row("EmployeeID").ToString()
            Dim nwe As New NorthwindEmployee(id)
            ' Add the NorthwindEmployee object to the collection.
            al.Add(nwe)
         Next
      Finally
         ' If anything strange happens, clean up.
         sds.Dispose()
      End Try

      Return al
   End Function 'GetAllEmployees

   Public Shared Function GetEmployee(anID As Object) As NorthwindEmployee
      Return New NorthwindEmployee(anID)
   End Function 'GetEmployee


   Public Shared Sub UpdateEmployeeInfo(ne As NorthwindEmployee)
      Dim retval As Boolean = ne.Save()
      If Not retval Then
         Throw New NorthwindDataException("UpdateEmployee failed.")
      End If
   End Sub

   Public Shared Sub DeleteEmployee(ne As NorthwindEmployee)
   End Sub

End Class


Public Class NorthwindEmployee


   Public Sub New()
      ID = DBNull.Value
      aLastName = ""
      aFirstName = ""
      aTitle = ""
      titleOfCourtesy = ""
      reportsTo = - 1
   End Sub


   Public Sub New(anID As Object)
      Me.ID = anID
      Dim cts As ConnectionStringSettings = ConfigurationManager.ConnectionStrings("NorthwindConnection")
      Dim conn As New SqlConnection(cts.ConnectionString)
      Dim sc As New SqlCommand(" SELECT FirstName,LastName,Title,TitleOfCourtesy,ReportsTo " & _
                               " FROM Employees " & _
                               " WHERE EmployeeID = @empId", conn)
      ' Add the employee ID parameter and set its value.
      sc.Parameters.Add(New SqlParameter("@empId", SqlDbType.Int)).Value = Int32.Parse(anID.ToString())
      Dim sdr As SqlDataReader = Nothing

      Try
         conn.Open()
         sdr = sc.ExecuteReader()

         ' This is not a while loop. It only loops once.
         If Not (sdr Is Nothing) AndAlso sdr.Read() Then
            ' The IEnumerable contains DataRowView objects.
            Me.aFirstName = sdr("FirstName").ToString()
            Me.aLastName = sdr("LastName").ToString()
            Me.aTitle = sdr("Title").ToString()
            Me.titleOfCourtesy = sdr("TitleOfCourtesy").ToString()
            If Not sdr.IsDBNull(4) Then
               Me.reportsTo = sdr.GetInt32(4)
            End If
         Else
            Throw New NorthwindDataException("Data not loaded for employee id.")
         End If
      Finally
         Try
            If Not (sdr Is Nothing) Then
               sdr.Close()
            End If
            conn.Close()
         Catch se As SqlException
            ' Log an event in the Application Event Log.
            Throw
         End Try
      End Try
   End Sub

   Private ID As Object

   Private aLastName As String
   Public Property LastName() As String
      Get
         Return aLastName
      End Get
      Set
         aLastName = value
      End Set
   End Property

   Private aFirstName As String
   Public Property FirstName() As String
      Get
         Return aFirstName
      End Get
      Set
         aFirstName = value
      End Set
   End Property

   Private aTitle As String
   Public Property Title() As String
      Get
         Return aTitle
      End Get
      Set
         aTitle = value
      End Set
   End Property

   Private titleOfCourtesy As String
   Public Property Courtesy() As String
      Get
         Return titleOfCourtesy
      End Get
      Set
         titleOfCourtesy = value
      End Set
   End Property
   Private reportsTo As Integer

   Public Property Supervisor() As Integer
      Get
         Return reportsTo
      End Get
      Set
         reportsTo = value
      End Set
   End Property

   Public Function Save() As Boolean
      Return True
   End Function 'Save
End Class


Friend Class NorthwindDataException
   Inherits Exception

   Public Sub New(msg As String)
      MyBase.New(msg)
   End Sub
End Class
End Namespace

注解

本主题内容:

介绍

控件 ObjectDataSource 适用于你创建的类。 创建用于检索和更新数据的方法,并在标记中向 ObjectDataSource 控件提供这些方法的名称。 在呈现或回发处理期间,调用 ObjectDataSource 指定的方法。

控件没有可视化呈现 ObjectDataSource 。 因此, ObjectDataSource 不支持 或 SkinID 属性等EnableTheming视觉功能。

目的

一种非常常见的应用程序设计做法是将表示层与业务逻辑分开,并将业务逻辑封装在业务对象中。 这些业务对象在表示层和数据层之间形成一个不同的层,形成三层应用程序体系结构。 该 ObjectDataSource 控件使开发人员能够使用 ASP.NET 数据源控件,同时保留其三层应用程序体系结构。

控件 ObjectDataSource 使用反射来创建业务对象的实例,并对其调用方法来检索、更新、插入和删除数据。 属性 TypeName 标识使用 的类 ObjectDataSource 的名称。 控件 ObjectDataSource 为每个方法调用创建并销毁 类的实例;它在 Web 请求的生存期内不会将 对象保存在内存中。 如果你使用的业务对象需要许多资源,或者创建和销毁成本高昂,这是一个严肃的考虑因素。 使用昂贵的对象可能不是最佳设计选择,但可以使用 、 ObjectCreatedObjectDisposing 事件来控制对象的ObjectCreating生命周期。

注意

SelectMethodUpdateMethodInsertMethodDeleteMethod 属性标识的方法可以是实例方法,也可以static是 Visual Basic) Shared 方法中的 (。 如果在 Visual Basic) 中 (方法static,则不会创建业务对象的实例,也不会ObjectCreating引发 、 ObjectCreatedObjectDisposingShared 事件。

检索数据

若要从业务对象检索数据,请将 SelectMethod 属性设置为检索数据的方法的名称。 如果 方法不返回 IEnumerableDataSet 对象,则 该对象由集合中的 IEnumerable 运行时包装。 如果方法签名具有参数,则可以将 对象添加到 Parameter 集合中 SelectParameters ,然后将其绑定到要传递给 由 SelectMethod 属性指定的方法的值。 为了使 ObjectDataSource 控件使用参数,参数必须与方法签名中参数的名称和类型匹配。 有关详细信息,请参阅 将参数与 ObjectDataSource 控件配合使用

每当调用 方法时, 控件 ObjectDataSourceSelect 检索数据。 此方法提供对属性指定的方法的 SelectMethod 编程访问。 由 SelectMethod 属性指定的 方法在调用其DataBind方法时,由绑定到 ObjectDataSource 的控件自动调用。 如果设置 DataSourceID 数据绑定控件的 属性,控件会根据需要自动绑定到数据源中的数据。 DataSourceID设置 属性是将控件绑定到ObjectDataSource数据绑定控件的推荐方法。 或者,可以设置 DataSource 属性,但必须显式调用 DataBind 数据绑定控件的 方法。 可以随时以编程方式调用 Select 方法以检索数据。

有关将数据绑定控件绑定到数据源控件的详细信息,请参阅 使用数据源控件绑定到数据

执行数据操作

根据控件使用的业务对象 ObjectDataSource 的功能,可以执行数据操作,例如更新、插入和删除。 若要执行这些数据操作,请为要执行的操作设置适当的方法名称和任何关联的参数。 例如,对于更新操作,请将 UpdateMethod 属性设置为执行更新并将任何所需参数添加到 UpdateParameters 集合的业务对象方法的名称。 如果控件 ObjectDataSource 与数据绑定控件相关联,则参数由数据绑定控件添加。 在这种情况下,需要确保 方法的参数名称与数据绑定控件中的字段名称匹配。 更新是在由代码显式调用或由数据绑定控件自动调用 方法时 Update 执行的。 和 Insert 操作遵循Delete相同的常规模式。 假定业务对象一次一条记录执行这些类型的数据操作,而不是批处理。

筛选数据

如果数据作为 DataSetDataTable 对象返回,则ObjectDataSource控件可以筛选由 SelectMethod 属性检索的数据。 可以使用格式字符串语法将 属性设置为 FilterExpression 筛选表达式,并将表达式中的值绑定到集合中指定的 FilterParameters 参数。

缓存

ObjectDataSource虽然 不会跨多个请求保留业务对象的实例,但它可以缓存调用 由 SelectMethod 属性标识的方法的结果。 缓存数据时,对 方法的后续调用 Select 将返回缓存的数据,而不是创建业务对象并使用反射调用其 SelectMethod 。 通过缓存,可以避免创建对象并调用其数据方法,而代价是 Web 服务器上的内存。 ObjectDataSource当 属性设置为 trueEnableCaching,会自动缓存数据,CacheDuration并将 属性设置为缓存在放弃缓存之前存储数据的秒数。 还可以指定 CacheExpirationPolicy 属性和可选 SqlCacheDependency 属性。 控件 ObjectDataSource 允许缓存所有类型的数据,但不应缓存保留资源或状态的对象,这些对象不能共享为多个请求提供服务 (例如打开 SqlDataReader 的对象) ,因为对象的同一实例将用于为多个请求提供服务。

功能

下表描述了 控件的功能 ObjectDataSource

功能 要求
选择 SelectMethod 属性设置为选择数据的业务对象方法的名称,并通过编程方式或使用数据绑定控件在集合中包含 SelectParameters 任何必要的参数。
排序 SortParameterName 属性设置为承载排序条件的方法中的 SelectMethod 参数的名称。
Filtering FilterExpression 属性设置为筛选表达式,并选择性地将任何参数添加到集合, FilterParameters 以在调用 方法时 Select 筛选数据。 由 属性指定的 SelectMethod 方法必须返回 DataSetDataTable
分页 如果 SelectMethod 方法包含要检索的最大记录数的参数以及要检索的第一个记录的索引,则支持数据源分页。 必须在 和 StartRowIndexParameterName 属性中MaximumRowsParameterName分别设置这些参数的名称。 数据绑定控件可能能够自行执行分页,即使控件 ObjectDataSource 不支持直接在 属性指定的 SelectMethod 方法中分页。 数据绑定控件要能够执行此操作的要求是 属性指定的 SelectMethod 方法返回实现 接口的对象 ICollection
更新 UpdateMethod 属性设置为用于更新数据并在集合中包含 UpdateParameters 任何必要参数的业务对象方法的名称。
正在删除 DeleteMethod 属性设置为删除数据的业务对象方法或函数的名称,并在集合中包含 DeleteParameters 任何必要的参数。
插入 InsertMethod 属性设置为插入数据的业务对象方法或函数的名称,并在集合中包含 InsertParameters 任何必要的参数。
缓存 EnableCaching 属性设置为 trueCacheDuration 并根据缓存数据的缓存行为将 和 CacheExpirationPolicy 属性。

注意

使用 ObjectDataSource 类更新或插入数据时,在客户端上输入的字符串不会自动从客户端区域性格式转换为服务器区域性格式。 例如,客户端区域性可能指定 DD/MM/YYYY 作为日期格式,服务器上的日期格式可能是 MM/DD/YYYY。 在这种情况下,2009 年 10 月 5 日将进入 TextBox 控制,作为 2009/5/10,但将解释为 2009 年 5 月 10 日。 2009 年 10 月 15 日将输入为 2009/10/15,并将作为无效日期被拒绝。

数据视图

与所有数据源控件一样,控件 ObjectDataSource 与数据源视图类相关联。 虽然 控件 ObjectDataSource 是页面开发人员用于处理数据的接口, ObjectDataSourceView 但 类是数据绑定控件使用的接口。 此外, ObjectDataSourceView 类描述数据源控件的功能,并执行实际工作。 控件 ObjectDataSource 只有一个关联的 ObjectDataSourceView,并且它始终名为 DefaultViewObjectDataSourceView虽然 对象由 GetView 方法公开,但其许多属性和方法都由 ObjectDataSource 控件直接包装和公开。 对象在后台 ObjectDataSourceView 执行所有数据操作,包括检索、插入、更新、删除、筛选和排序数据。 有关详细信息,请参阅 ObjectDataSourceView

使用 LINQ to SQL

可以将 控件与 LINQ to SQL 类一起使用 ObjectDataSource 。 为此,请将 属性设置为 TypeName 数据上下文类的名称。 还可以将 SelectMethodUpdateMethodInsertMethodDeleteMethod 方法设置为数据上下文类中执行相应操作的方法。 必须为 ObjectDisposing 事件创建事件处理程序才能取消释放数据上下文类。 此步骤是必需的,因为 LINQ to SQL 支持延迟执行,而 ObjectDataSource 控件会尝试在 Select 操作后释放数据上下文。 有关如何创建 LINQ to SQL 类的详细信息,请参阅 如何:在 Web 项目中创建 LINQ to SQL 类。 有关如何取消释放数据上下文类的示例,请参阅 ObjectDisposing 事件。

使用实体框架

还可以将 ObjectDataSource 控件与实体框架一起使用。 有关详细信息,请参阅 使用实体框架和 ObjectDataSource 控件

声明性语法

<asp:ObjectDataSource
    CacheDuration="string|Infinite"
    CacheExpirationPolicy="Absolute|Sliding"
    CacheKeyDependency="string"
    ConflictDetection="OverwriteChanges|CompareAllValues"
    ConvertNullToDBNull="True|False"
    DataObjectTypeName="string"
    DeleteMethod="string"
    EnableCaching="True|False"
    EnablePaging="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    FilterExpression="string"
    ID="string"
    InsertMethod="string"
    MaximumRowsParameterName="string"
    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"
    OnObjectCreated="ObjectCreated event handler"
    OnObjectCreating="ObjectCreating event handler"
    OnObjectDisposing="ObjectDisposing 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"
    runat="server"
    SelectCountMethod="string"
    SelectMethod="string"
    SkinID="string"
    SortParameterName="string"
    SqlCacheDependency="string"
    StartRowIndexParameterName="string"
    TypeName="string"
    UpdateMethod="string"
    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:ObjectDataSource>

构造函数

ObjectDataSource()

初始化 ObjectDataSource 类的新实例。

ObjectDataSource(String, String)

使用指定的类型名和数据检索方法名初始化 ObjectDataSource 类的新实例。

属性

Adapter

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

(继承自 Control)
AppRelativeTemplateSourceDirectory

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

(继承自 Control)
BindingContainer

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

(继承自 Control)
CacheDuration

获取或设置以秒为单位的一段时间,数据源控件就在这段时间内缓存 SelectMethod 属性检索到的数据。

CacheExpirationPolicy

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

CacheKeyDependency

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

ChildControlsCreated

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

(继承自 Control)
ClientID

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

(继承自 DataSourceControl)
ClientIDMode

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

(继承自 DataSourceControl)
ClientIDSeparator

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

(继承自 Control)
ConflictDetection

获取或设置一个值,该值确定是仅将新值传递给 Update 方法,还是将旧值和新值都传递给 Update 方法。

Context

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

(继承自 Control)
Controls

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

(继承自 DataSourceControl)
ConvertNullToDBNull

获取或设置一个值,该值指示传递给更新、插入或删除操作的 Parameter 值是否由 Value 控件自动从 null 转换为 ObjectDataSource 值。

DataItemContainer

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

(继承自 Control)
DataKeysContainer

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

(继承自 Control)
DataObjectTypeName

获取或设置某个类的名称,ObjectDataSource 控件将该类用于更新、插入或删除数据操作中的参数,而不是从数据绑定控件传递个别的值。

DeleteMethod

获取或设置由 ObjectDataSource 控件调用以删除数据的方法或函数的名称。

DeleteParameters

获取参数集合,该集合包含由 DeleteMethod 方法使用的参数。

DesignMode

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

(继承自 Control)
EnableCaching

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

EnablePaging

获取或设置一个值,该值指示数据源控件是否支持对它检索的数据集进行分页。

EnableTheming

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

(继承自 DataSourceControl)
EnableViewState

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

(继承自 Control)
Events

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

(继承自 Control)
FilterExpression

获取或设置当调用由 SelectMethod 属性指定的方法时应用的筛选表达式。

FilterParameters

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

HasChildViewState

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

(继承自 Control)
ID

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

(继承自 Control)
IdSeparator

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

(继承自 Control)
InsertMethod

获取或设置由 ObjectDataSource 控件调用以插入数据的方法或函数的名称。

InsertParameters

获取参数集合,该集合包含由 InsertMethod 属性使用的参数。

IsChildControlStateCleared

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

(继承自 Control)
IsTrackingViewState

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

(继承自 Control)
IsViewStateEnabled

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

(继承自 Control)
LoadViewStateByID

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

(继承自 Control)
MaximumRowsParameterName

获取或设置业务对象数据检索方法参数的名称,该参数用于指示要检索的数据源分页支持的记录数。

NamingContainer

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

(继承自 Control)
OldValuesParameterFormatString

获取或设置一个格式字符串,该字符串应用于传递给 DeleteUpdate 方法的原始值的参数名称。

Page

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

(继承自 Control)
Parent

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

(继承自 Control)
ParsingCulture

当将字符串值转换为实际属性类型来构造由 DataObjectTypeName 指示的对象类型时,获取或设置表示哪些区域性信息被用了的值。

RenderingCompatibility

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

(继承自 Control)
SelectCountMethod

获取或设置 ObjectDataSource 控件调用以检索行数的方法或函数的名称。

SelectMethod

获取或设置 ObjectDataSource 控件调用以检索数据的方法或函数的名称。

SelectParameters

获取参数的集合,这些参数由 SelectMethod 属性指定的方法使用。

Site

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

(继承自 Control)
SkinID

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

(继承自 DataSourceControl)
SortParameterName

获取或设置业务对象的名称,SelectMethod 参数使用此业务对象指定数据源排序支持的排序表达式。

SqlCacheDependency

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

StartRowIndexParameterName

获取或设置数据检索方法参数的名称,该参数用于指示为数据源分页支持检索的第一条记录的标识符的值。

TemplateControl

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

(继承自 Control)
TemplateSourceDirectory

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

(继承自 Control)
TypeName

获取或设置 ObjectDataSource 对象表示的类的名称。

UniqueID

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

(继承自 Control)
UpdateMethod

获取或设置由 ObjectDataSource 控件调用以更新数据的方法或函数的名称。

UpdateParameters

获取参数集合,该集合包含由 UpdateMethod 属性指定的方法使用的参数。

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)
DataBind()

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

(继承自 Control)
DataBind(Boolean)

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

(继承自 Control)
DataBindChildren()

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

(继承自 Control)
Delete()

通过用 DeleteMethod 集合中的所有参数调用由 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)
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()

检索名称的集合,这些名称表示与 ObjectDataSource 对象关联的视图对象的列表。

HasControls()

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

(继承自 DataSourceControl)
HasEvents()

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

(继承自 Control)
Insert()

通过调用由 InsertMethod 属性标识的方法和 InsertParameters 集合中的所有参数,执行插入操作。

IsLiteralContent()

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

(继承自 Control)
LoadControlState(Object)

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

(继承自 Control)
LoadViewState(Object)

加载以前保存的 ObjectDataSource 控件的视图状态。

MapPathSecure(String)

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

(继承自 Control)
MemberwiseClone()

创建当前 Object 的浅表副本。

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

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

(继承自 Control)
OnDataBinding(EventArgs)

引发 DataBinding 事件。

(继承自 Control)
OnInit(EventArgs)

LoadComplete 事件处理程序添加到包含 ObjectDataSource 控件的页。

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

保存 ObjectDataSource 控件的状态。

Select()

通过用 SelectMethod 集合中的参数调用由 SelectParameters 属性标识的方法,从基础数据存储中检索数据。

SetDesignModeState(IDictionary)

为控件设置设计时数据。

(继承自 Control)
SetRenderMethodDelegate(RenderMethod)

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

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

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

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

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

(继承自 Control)
ToString()

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

(继承自 Object)
TrackViewState()

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

Update()

通过调用 UpdateMethod 属性标识的方法和 UpdateParameters 集合中的所有参数,执行更新操作。

事件

DataBinding

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

(继承自 Control)
Deleted

Delete() 操作完成时发生。

Deleting

Delete() 操作前发生。

Disposed

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

(继承自 Control)
Filtering

执行筛选操作前发生。

Init

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

(继承自 Control)
Inserted

Insert() 操作完成时发生。

Inserting

Insert() 操作前发生。

Load

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

(继承自 Control)
ObjectCreated

在创建由 TypeName 属性标识的对象之后发生。

ObjectCreating

在创建由 TypeName 属性标识的对象之前发生。

ObjectDisposing

在丢弃由 TypeName 属性标识的对象之前发生。

PreRender

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

(继承自 Control)
Selected

Select() 操作完成时发生。

Selecting

Select() 操作前发生。

Unload

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

(继承自 Control)
Updated

Update() 操作完成时发生。

Updating

Update() 操作前发生。

显式接口实现

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)

确定表元数据是否可用。

适用于

另请参阅