ObjectDataSource 类

定义

表示为多层 Web 应用程序体系结构中的数据绑定控件提供数据的业务对象。Represents a business object that provides data to data-bound controls in multitier Web application architectures.

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

示例

本主题提供了包含源代码的 Visual Studio 网站项目:下载A Visual Studio Web site project with source code is available to accompany this topic: Download.

本部分显示 .aspx 页中标记的 ObjectDataSource,并显示它使用的业务对象。This section shows an ObjectDataSource in markup in an .aspx page and it shows the business objects that it works with. 示例是 .aspx 页。The example is the .aspx page. 它包含绑定到 ObjectDataSource 控件的 GridView 控件。It contains a GridView control that is bound to an ObjectDataSource control. ObjectDataSource 控件标记指定业务对象的名称,并指定要为检索数据而调用的业务对象方法的名称。The ObjectDataSource control markup specifies the name of the business object and the name of the business object method to call in order to retrieve data.

<%@ 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 控件使用的业务对象。The following example shows the business object that the ObjectDataSource control in the .aspx page uses. (许多其他 ObjectDataSource 代码示例也使用此业务对象。)该示例包含以下两个基本类:(Many other ObjectDataSource code examples use this business object also.) The example consists of the following two basic classes:

  • EmployeeLogic 类是 ObjectDataSource 使用的业务逻辑类。The EmployeeLogic class is the business logic class that the ObjectDataSource uses.

  • NorthwindEmployee 类定义由 EmployeeLogic 类的 GetAllEmployees 方法返回的数据对象。The NorthwindEmployee class defines the data object that is returned by the GetAllEmployees method of the EmployeeLogic class.

提供额外的 NorthwindDataException 类是一种方便的方式。An additional NorthwindDataException class is provided as a convenience.

这组示例类适用于 Northwind 商贸数据库,可用于 Microsoft SQL Server 和 Microsoft Access。This set of example classes works with the Northwind Traders database, which is available with Microsoft SQL Server and Microsoft Access. 若要获取完整的工作示例,必须使用所提供的 .aspx 页示例来编译并使用这些类。For a complete working example, you must compile and use these classes with the .aspx page example that is provided.

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

注解

本主题内容:In this topic:

介绍Introduction

ObjectDataSource 控件适用于你创建的类。An ObjectDataSource control works with a class that you create. 创建检索和更新数据的方法,并向标记中的 ObjectDataSource 控件提供这些方法的名称。You create methods that retrieve and update data, and you provide the names of those methods to the ObjectDataSource control in markup. 在呈现或回发处理期间,ObjectDataSource 会调用您指定的方法。During rendering or postback processing, the ObjectDataSource calls the methods that you have specified.

没有 ObjectDataSource 控件的可视呈现。There is no visual rendering of the ObjectDataSource control. 因此,ObjectDataSource 不支持视觉功能,如 EnableThemingSkinID 属性。As a result, the ObjectDataSource does not support visual features such as the EnableTheming or SkinID property.

目的Purpose

一种很常见的应用程序设计做法是将表示层与业务逻辑分离,并在业务对象中封装业务逻辑。A very common application design practice is to separate the presentation layer from business logic and to encapsulate the business logic in business objects. 这些业务对象在表示层和数据层之间形成了一个不同的层,产生了三层应用程序体系结构。These business objects form a distinct layer between the presentation layer and the data tier, resulting in a three-tier application architecture. ObjectDataSource 控件使开发人员可以使用 ASP.NET 数据源控件,同时保留其三层应用程序体系结构。The ObjectDataSource control enables developers to use an ASP.NET data source control while retaining their three-tier application architecture.

ObjectDataSource 控件使用反射来创建业务对象的实例,并对其调用方法以检索、更新、插入和删除数据。The ObjectDataSource control uses reflection to create instances of business objects and to call methods on them to retrieve, update, insert, and delete data. TypeName 属性标识 ObjectDataSource 使用的类的名称。The TypeName property identifies the name of the class that the ObjectDataSource works with. ObjectDataSource 控件创建并销毁每个方法调用的类的实例;它在 Web 请求的生存期内不会将对象保存在内存中。The ObjectDataSource control creates and destroys an instance of the class for each method call; it does not hold the object in memory for the lifetime of the Web request. 如果你使用的业务对象需要多个资源,或者创建和销毁开销较高,则这是一个重要的考虑因素。This is a serious consideration if the business object that you use requires many resources or is otherwise expensive to create and destroy. 使用昂贵的对象可能不是最佳的设计选择,但可以使用 ObjectCreatingObjectCreatedObjectDisposing 事件控制对象的生命周期。Using an expensive object might not be an optimal design choice, but you can control the life cycle of the object by using the ObjectCreating, ObjectCreated, and ObjectDisposing events.

备注

SelectMethodUpdateMethodInsertMethodDeleteMethod 属性标识的方法可以是实例方法或 staticShared)方法。The methods that are identified by the SelectMethod, UpdateMethod, InsertMethod, and DeleteMethod properties can be instance methods or static (Shared in Visual Basic) methods. 如果 static 方法(Shared 在 Visual Basic 中),则不会创建业务对象的实例,并且不会引发 ObjectCreatingObjectCreatedObjectDisposing 事件。If the methods are static (Shared in Visual Basic), an instance of the business object is not created, and the ObjectCreating, ObjectCreated, and ObjectDisposing events are not raised.

检索数据Retrieving Data

若要从业务对象中检索数据,请将 SelectMethod 属性设置为用于检索数据的方法的名称。To retrieve data from a business object, set the SelectMethod property to the name of the method that retrieves data. 如果该方法未返回 IEnumerableDataSet 对象,则运行时在 IEnumerable 集合中包装对象。If the method does not return an IEnumerable or DataSet object, the object is wrapped by the runtime in an IEnumerable collection. 如果方法签名具有参数,则可以将 Parameter 对象添加到 SelectParameters 集合,然后将这些对象绑定到要传递给 SelectMethod 属性指定的方法的值。If the method signature has parameters, you can add Parameter objects to the SelectParameters collection, and then bind them to the values that you want to pass to the method that is specified by the SelectMethod property. 为了使 ObjectDataSource 控件使用这些参数,这些参数必须与方法签名中的参数的名称和类型相匹配。In order for the ObjectDataSource control to use the parameters, the parameters must match the names and types of the parameters in the method signature. 有关详细信息,请参阅将参数用于 ObjectDataSource 控件For more information, see Using Parameters with the ObjectDataSource Control.

只要调用 Select 方法,ObjectDataSource 控件就会检索数据。The ObjectDataSource control retrieves data whenever the Select method is called. 此方法提供对 SelectMethod 属性指定的方法的编程访问。This method provides programmatic access to the method that is specified by SelectMethod property. 当调用其 DataBind 方法时,绑定到 ObjectDataSource 的控件会自动调用由 SelectMethod 属性指定的方法。The method that is specified by the SelectMethod property is called automatically by controls that are bound to the ObjectDataSource when their DataBind method is called. 如果设置数据绑定控件的 DataSourceID 属性,则控件会根据需要自动绑定到数据源中的数据。If you set the DataSourceID property of a data-bound control, the control automatically binds to data from the data source, as needed. 设置 DataSourceID 属性是将 ObjectDataSource 控件绑定到数据绑定控件的建议方法。Setting the DataSourceID property is the recommended method for binding an ObjectDataSource control to a data-bound control. 另外,还可以设置 DataSource 属性,但必须显式调用数据绑定控件的 DataBind 方法。Alternatively, you can set the DataSource property, but then you must explicitly call the DataBind method of the data-bound control. 您可以随时以编程方式调用 Select 方法来检索数据。You can call the Select method programmatically at any time to retrieve data.

有关将数据绑定控件绑定到数据源控件的详细信息,请参阅使用数据源控件绑定到数据For more information about binding data-bound controls to data source controls, see Binding to Data Using a Data Source Control.

执行数据操作Performing Data Operations

根据 ObjectDataSource 控件处理的业务对象的功能,您可以执行数据操作,例如更新、插入和删除。Depending on the capabilities of the business object that the ObjectDataSource control works with, you can perform data operations, such as updates, insertions, and deletions. 若要执行这些数据操作,请为要执行的操作设置适当的方法名称和任何关联参数。To perform these data operations, set the appropriate method name and any associated parameters for the operation that you want to perform. 例如,对于更新操作,将 UpdateMethod 属性设置为业务对象方法的名称,该方法执行更新并将任何所需参数添加到 UpdateParameters 集合。For example, for an update operation, set the UpdateMethod property to the name of the business object method that performs updates and add any required parameters to the UpdateParameters collection. 如果 ObjectDataSource 控件与数据绑定控件关联,则由数据绑定控件添加参数。If the ObjectDataSource control is associated with a data-bound control, the parameters are added by the data-bound control. 在这种情况下,需要确保方法的参数名称与数据绑定控件中的字段名称匹配。In this case, you need to ensure that the parameter names of the method match the field names in the data-bound control. 更新是在调用 Update 方法时执行的,无论是通过代码显式调用,还是由数据绑定控件自动执行。The update is performed when the Update method is called, either explicitly by your code or automatically by a data-bound control. DeleteInsert 操作遵循相同的常规模式。The same general pattern is followed for Delete and Insert operations. 假定业务对象一次一条记录执行这些类型的数据操作,而不是分批执行。Business objects are assumed to perform these types of data operations one record at a time, rather than batched.

筛选数据Filtering Data

如果数据作为 DataSetDataTable 对象返回,则 ObjectDataSource 控件可以筛选 SelectMethod 属性检索的数据。The ObjectDataSource control can filter data that is retrieved by the SelectMethod property, if the data is returned as a DataSet or DataTable object. 您可以使用格式字符串语法将 FilterExpression 属性设置为筛选表达式,并将表达式中的值绑定到 FilterParameters 集合中指定的参数。You can set the FilterExpression property to a filtering expression by using a format string syntax and bind values in the expression to parameters that are specified in the FilterParameters collection.

CachingCaching

尽管 ObjectDataSource 不会在多个请求中保留业务对象的实例,但它可以缓存调用由 SelectMethod 属性标识的方法的结果。Although the ObjectDataSource does not retain the instance of the business object across multiple requests, it can cache the result of calling the method identified by the SelectMethod property. 在缓存数据时,对 Select 方法的后续调用会返回缓存的数据,而不是创建业务对象并使用反射调用其 SelectMethodWhile the data is cached, subsequent calls to the Select method return the cached data instead of creating the business object and calling its SelectMethod using reflection. 缓存使你可以避免创建对象并以 Web 服务器上的内存的代价调用其数据方法。Caching lets you avoid creating the object and calling its data method at the expense of memory on the Web server. EnableCaching 属性设置为 true时,ObjectDataSource 会自动缓存数据,CacheDuration 属性设置为缓存在丢弃之前存储数据的秒数。The ObjectDataSource automatically caches data when the EnableCaching property is set to true, and the CacheDuration property is set to the number of seconds that the cache stores data before the cache is discarded. 还可以指定 CacheExpirationPolicy 属性和可选的 SqlCacheDependency 属性。You can also specify a CacheExpirationPolicy property and an optional SqlCacheDependency property. ObjectDataSource 控件允许缓存各种类型的数据,但不应缓存保留无法共享来服务多个请求(例如,打开的 SqlDataReader 对象)的资源或状态的对象,因为该对象的同一实例将用于为多个请求提供服务。The ObjectDataSource control allows you to cache all types of data, but you should not cache objects that retain resources or state that cannot be shared to service multiple requests (for example, an open SqlDataReader object), because the same instance of the object will be used to service multiple requests.

功能Features

下表描述了 ObjectDataSource 控件的功能。The following table describes the features of the ObjectDataSource control.

功能Capability 要求Requirements
选择Selecting SelectMethod 属性设置为业务对象方法的名称,该方法可选择数据,并以编程方式或通过使用数据绑定控件包含 SelectParameters 集合中的任何必要参数。Set the SelectMethod property to the name of the business object method that selects data, and include any necessary parameters in the SelectParameters collection either programmatically or by using a data-bound control.
排序Sorting SortParameterName 属性设置为带有排序条件的 SelectMethod 方法中的参数的名称。Set the SortParameterName property to the name of the parameter in the SelectMethod method that carries the sort criteria.
FilteringFiltering FilterExpression 属性设置为筛选表达式,并(可选)将任何参数添加到 FilterParameters 集合,以便在调用 Select 方法时筛选数据。Set the FilterExpression property to a filtering expression and optionally add any parameters to the FilterParameters collection to filter the data when the Select method is called. SelectMethod 属性指定的方法必须返回 DataSetDataTableThe method specified by the SelectMethod property must return a DataSet or DataTable.
PagingPaging 如果 SelectMethod 方法包含要检索的最大记录数的参数和要检索的第一条记录的索引,则支持数据源分页。Data source paging is supported, if the SelectMethod method contains parameters for the maximum number of records to retrieve and the index of the first record to retrieve. 必须分别在 "MaximumRowsParameterName" 和 "StartRowIndexParameterName" 属性中设置这些参数的名称。The names of those parameters must be set in the MaximumRowsParameterName and StartRowIndexParameterName properties, respectively. 即使 ObjectDataSource 控件不支持直接在由 SelectMethod 属性指定的方法中进行分页,数据绑定控件也可能能够执行分页。A data-bound control might be able to perform paging itself, even if the ObjectDataSource control does not support paging directly in the method specified by the SelectMethod property. 数据绑定控件实现此目的的要求是,由 SelectMethod 属性指定的方法返回实现 ICollection 接口的对象。The requirement for the data-bound control to be able to do this is that the method specified by the SelectMethod property return an object that implements the ICollection interface.
更新Updating UpdateMethod 属性设置为用于更新数据的业务对象方法的名称,并在 UpdateParameters 集合中包含所有必需的参数。Set the UpdateMethod property to the name of the business object method that updates data, and include any necessary parameters in the UpdateParameters collection.
正在删除Deleting DeleteMethod 属性设置为用于删除数据的业务对象方法或函数的名称,并在 DeleteParameters 集合中包含所有必需的参数。Set the DeleteMethod property to the name of the business object method or function that deletes data, and include any necessary parameters in the DeleteParameters collection.
插入Inserting InsertMethod 属性设置为业务对象方法的名称或插入数据的函数,并在 InsertParameters 集合中包含所有必要的参数。Set the InsertMethod property to the name of the business object method or function that inserts data, and include any necessary parameters in the InsertParameters collection.
CachingCaching 根据所需的缓存数据缓存行为,将 EnableCaching 属性设置为 true,以及 CacheDurationCacheExpirationPolicy 属性。Set the EnableCaching property to true, and the CacheDuration and CacheExpirationPolicy properties according to the caching behavior you want for your cached data.

备注

当你使用 ObjectDataSource 类来更新或插入数据时,在客户端上输入的字符串不会自动从客户端区域性格式转换为服务器区域性格式。When you use the ObjectDataSource class to update or insert data, strings that are entered at the client are not automatically converted from the client culture format to the server culture format. 例如,客户端区域性可能将 DD/MM/YYYY 指定为日期格式,而服务器上的日期格式可能为 MM/DD/YYYY。For example, the client culture might specify DD/MM/YYYY as the date format, and the date format on the server might be MM/DD/YYYY. 在这种情况下,10月5日,2009将作为5/10/2009 输入 TextBox 控件中,但将被解释为5月 10 2009 日。In that case, October 5, 2009 would be entered in a TextBox control as 5/10/2009 but would be interpreted as May 10, 2009. 2009年10月15日将输入为15/10/2009,并将被拒绝为无效日期。October 15, 2009 would be entered as 15/10/2009, and would be rejected as an invalid date.

数据视图Data View

与所有数据源控件一样,ObjectDataSource 控件与数据源视图类相关联。As with all data source controls, the ObjectDataSource control is associated with a data source view class. 虽然 ObjectDataSource 控件是页面开发人员用来处理数据的接口,但 ObjectDataSourceView 类是数据绑定控件所使用的接口。While the ObjectDataSource control is the interface that the page developer uses to work with data, the ObjectDataSourceView class is the interface that data-bound controls work with. 此外,ObjectDataSourceView 类描述数据源控件的功能,并执行实际工作。Additionally, the ObjectDataSourceView class describes the capabilities of the data source control, and performs the actual work. ObjectDataSource 控件只有一个关联 ObjectDataSourceView,并且它始终命名为 "DefaultView"。The ObjectDataSource control has only one associated ObjectDataSourceView, and it is always named DefaultView. GetView 方法公开 ObjectDataSourceView 对象时,它的许多属性和方法会直接由 ObjectDataSource 控件进行包装和公开。While the ObjectDataSourceView object is exposed by the GetView method, many of its properties and methods are wrapped and exposed directly by the ObjectDataSource control. 在后台,ObjectDataSourceView 对象执行所有数据操作,包括检索、插入、更新、删除、筛选数据和对数据进行排序。Behind the scenes, the ObjectDataSourceView object performs all data operations, including retrieving, inserting, updating, deleting, filtering, and sorting the data. 有关详细信息,请参阅 ObjectDataSourceViewFor more information, see ObjectDataSourceView.

使用 LINQ to SQLUsing LINQ to SQL

可以将 ObjectDataSource 控件与 LINQ to SQL 类结合使用。You can use the ObjectDataSource control with a LINQ to SQL class. 为此,请将 TypeName 属性设置为数据上下文类的名称。To do so, you set the TypeName property to the name of the data-context class. 还将 SelectMethodUpdateMethodInsertMethodDeleteMethod 方法设置为数据上下文类中执行相应操作的方法。You also set the SelectMethod, UpdateMethod, InsertMethod, and DeleteMethod methods to the methods in the data-context class that perform the corresponding operations. 您必须为 ObjectDisposing 事件创建事件处理程序,才能取消对数据上下文类的释放。You must create an event handler for the ObjectDisposing event in order to cancel disposing of the data-context class. 此步骤是必需的,因为 LINQ to SQL 支持延迟执行,而 ObjectDataSource 控件尝试在选择操作之后释放数据上下文。This step is necessary because LINQ to SQL supports deferred execution, whereas the ObjectDataSource control tries to dispose the data context after the Select operation. 有关如何创建 LINQ to SQL 类的详细信息,请参阅如何:在 Web 项目中创建 LINQ to SQL 类For more information about how to create LINQ to SQL classes, see How to: Create LINQ to SQL Classes in a Web Project. 有关如何取消数据上下文类的释放的示例,请参阅 ObjectDisposing 事件。For an example of how to cancel the disposing of a data context class, see the ObjectDisposing event.

使用实体框架Using the Entity Framework

您还可以将 ObjectDataSource 控件与实体框架结合使用。You can also use the ObjectDataSource control with the Entity Framework. 有关详细信息,请参阅使用实体框架和 ObjectDataSource 控件For more information, see Using the Entity Framework and the ObjectDataSource Control.

声明性语法Declarative Syntax

<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 类的新实例。Initializes a new instance of the ObjectDataSource class.

ObjectDataSource(String, String)

使用指定的类型名和数据检索方法名初始化 ObjectDataSource 类的新实例。Initializes a new instance of the ObjectDataSource class with the specified type name and data retrieval method name.

属性

Adapter

获取控件的浏览器特定适配器。Gets the browser-specific adapter for the control.

(继承自 Control)
AppRelativeTemplateSourceDirectory

获取或设置包含该控件的 PageUserControl 对象的应用程序相对虚拟目录。Gets or sets the application-relative virtual directory of the Page or UserControl object that contains this control.

(继承自 Control)
BindingContainer

获取包含该控件的数据绑定的控件。Gets the control that contains this control's data binding.

(继承自 Control)
CacheDuration

获取或设置以秒为单位的一段时间,数据源控件就在这段时间内缓存 SelectMethod 属性检索到的数据。Gets or sets the length of time, in seconds, that the data source control caches data that is retrieved by the SelectMethod property.

CacheExpirationPolicy

获取或设置缓存的到期行为,该行为与持续时间组合在一起可以描述数据源控件所用缓存的行为。Gets or sets the cache expiration behavior that, when combined with the duration, describes the behavior of the cache that the data source control uses.

CacheKeyDependency

获取或设置一个用户定义的键依赖项,该键依赖项链接到数据源控件创建的所有数据缓存对象。Gets or sets a user-defined key dependency that is linked to all data cache objects that are created by the data source control.

ChildControlsCreated

获取一个值,该值指示是否已创建服务器控件的子控件。Gets a value that indicates whether the server control's child controls have been created.

(继承自 Control)
ClientID

获取由 ASP.NET 生成的服务器控件标识符。Gets the server control identifier generated by ASP.NET.

(继承自 DataSourceControl)
ClientIDMode

此属性不用于数据源控件。This property is not used for data source controls.

(继承自 DataSourceControl)
ClientIDSeparator

获取一个字符值,该值表示 ClientID 属性中使用的分隔符字符。Gets a character value representing the separator character used in the ClientID property.

(继承自 Control)
ConflictDetection

获取或设置一个值,该值确定是仅将新值传递给 Update 方法,还是将旧值和新值都传递给 Update 方法。Gets or sets a value that determines whether or not just the new values are passed to the Update method or both the old and new values are passed to the Update method.

Context

为当前 Web 请求获取与服务器控件关联的 HttpContext 对象。Gets the HttpContext object associated with the server control for the current Web request.

(继承自 Control)
Controls

获取 ControlCollection 对象,该对象表示 UI 层次结构中的指定服务器控件的子控件。Gets a ControlCollection object that represents the child controls for a specified server control in the UI hierarchy.

(继承自 DataSourceControl)
ConvertNullToDBNull

获取或设置一个值,该值指示传递给更新、插入或删除操作的 Parameter 值是否由 null 控件自动从 Value 转换为 ObjectDataSource 值。Gets or sets a value indicating whether the Parameter values that are passed to an update, insert, or delete operation are automatically converted from null to the Value value by the ObjectDataSource control.

DataItemContainer

如果命名容器实现 IDataItemContainer,则获取对命名容器的引用。Gets a reference to the naming container if the naming container implements IDataItemContainer.

(继承自 Control)
DataKeysContainer

如果命名容器实现 IDataKeysControl,则获取对命名容器的引用。Gets a reference to the naming container if the naming container implements IDataKeysControl.

(继承自 Control)
DataObjectTypeName

获取或设置某个类的名称,ObjectDataSource 控件将该类用于更新、插入或删除数据操作中的参数,而不是从数据绑定控件传递个别的值。Gets or sets the name of a class that the ObjectDataSource control uses for a parameter in an update, insert, or delete data operation, instead of passing individual values from the data-bound control.

DeleteMethod

获取或设置由 ObjectDataSource 控件调用以删除数据的方法或函数的名称。Gets or sets the name of the method or function that the ObjectDataSource control invokes to delete data.

DeleteParameters

获取参数集合,该集合包含由 DeleteMethod 方法使用的参数。Gets the parameters collection that contains the parameters that are used by the DeleteMethod method.

DesignMode

获取一个值,该值指示是否正在使用设计图面上的一个控件。Gets a value indicating whether a control is being used on a design surface.

(继承自 Control)
EnableCaching

获取或设置一个值,该值指示 ObjectDataSource 控件是否启用数据缓存。Gets or sets a value indicating whether the ObjectDataSource control has data caching enabled.

EnablePaging

获取或设置一个值,该值指示数据源控件是否支持对它检索的数据集进行分页。Gets or sets a value that indicates whether the data source control supports paging through the set of data that it retrieves.

EnableTheming

获取一个值,该值指示此控件是否支持主题。Gets a value indicating whether this control supports themes.

(继承自 DataSourceControl)
EnableViewState

获取或设置一个值,该值指示服务器控件是否向发出请求的客户端保持自己的视图状态以及它所包含的任何子控件的视图状态。Gets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client.

(继承自 Control)
Events

获取控件的事件处理程序委托列表。Gets a list of event handler delegates for the control. 此属性是只读的。This property is read-only.

(继承自 Control)
FilterExpression

获取或设置当调用由 SelectMethod 属性指定的方法时应用的筛选表达式。Gets or sets a filtering expression that is applied when the method that is specified by the SelectMethod property is called.

FilterParameters

获取与 FilterExpression 字符串中的任何参数占位符关联的参数的集合。Gets a collection of parameters that are associated with any parameter placeholders in the FilterExpression string.

HasChildViewState

获取一个值,该值指示当前服务器控件的子控件是否具有任何已保存的视图状态设置。Gets a value indicating whether the current server control's child controls have any saved view-state settings.

(继承自 Control)
ID

获取或设置分配给服务器控件的编程标识符。Gets or sets the programmatic identifier assigned to the server control.

(继承自 Control)
IdSeparator

获取用于分隔控件标识符的字符。Gets the character used to separate control identifiers.

(继承自 Control)
InsertMethod

获取或设置由 ObjectDataSource 控件调用以插入数据的方法或函数的名称。Gets or sets the name of the method or function that the ObjectDataSource control invokes to insert data.

InsertParameters

获取参数集合,该集合包含由 InsertMethod 属性使用的参数。Gets the parameters collection that contains the parameters that are used by the InsertMethod property.

IsChildControlStateCleared

获取一个值,该值指示该控件中包含的控件是否具有控件状态。Gets a value indicating whether controls contained within this control have control state.

(继承自 Control)
IsTrackingViewState

获取一个值,用于指示服务器控件是否会将更改保存到其视图状态中。Gets a value that indicates whether the server control is saving changes to its view state.

(继承自 Control)
IsViewStateEnabled

获取一个值,该值指示是否为该控件启用了视图状态。Gets a value indicating whether view state is enabled for this control.

(继承自 Control)
LoadViewStateByID

获取一个值,该值指示控件是否通过 ID 而不是索引参与加载其视图状态。Gets a value indicating whether the control participates in loading its view state by ID instead of index.

(继承自 Control)
MaximumRowsParameterName

获取或设置业务对象数据检索方法参数的名称,该参数用于指示要检索的数据源分页支持的记录数。Gets or sets the name of the business object data retrieval method parameter that is used to indicate the number of records to retrieve for data source paging support.

NamingContainer

获取对服务器控件的命名容器的引用,此引用创建唯一的命名空间,以区分具有相同 ID 属性值的服务器控件。Gets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same ID property value.

(继承自 Control)
OldValuesParameterFormatString

获取或设置一个格式字符串,该字符串应用于传递给 DeleteUpdate 方法的原始值的参数名称。Gets or sets a format string to apply to the names of the parameters for original values that are passed to the Delete or Update methods.

Page

获取对包含服务器控件的 Page 实例的引用。Gets a reference to the Page instance that contains the server control.

(继承自 Control)
Parent

获取对页 UI 层次结构中服务器控件的父控件的引用。Gets a reference to the server control's parent control in the page control hierarchy.

(继承自 Control)
ParsingCulture

当将字符串值转换为实际属性类型来构造由 DataObjectTypeName 指示的对象类型时,获取或设置表示哪些区域性信息被用了的值。Gets a or sets a value that indicates what culture information is used when converting string values to actual property types in order to construct an object of the type indicated by DataObjectTypeName.

RenderingCompatibility

获取一个值,该值指定呈现的 HTML 将与之兼容的 ASP.NET 版本。Gets a value that specifies the ASP.NET version that rendered HTML will be compatible with.

(继承自 Control)
SelectCountMethod

获取或设置 ObjectDataSource 控件调用以检索行数的方法或函数的名称。Gets or sets the name of the method or function that the ObjectDataSource control invokes to retrieve a row count.

SelectMethod

获取或设置 ObjectDataSource 控件调用以检索数据的方法或函数的名称。Gets or sets the name of the method or function that the ObjectDataSource control invokes to retrieve data.

SelectParameters

获取参数的集合,这些参数由 SelectMethod 属性指定的方法使用。Gets a collection of parameters that are used by the method specified by the SelectMethod property.

Site

获取容器信息,该容器在呈现于设计图面上时承载当前控件。Gets information about the container that hosts the current control when rendered on a design surface.

(继承自 Control)
SkinID

获取要应用于 DataSourceControl 控件的外观。Gets the skin to apply to the DataSourceControl control.

(继承自 DataSourceControl)
SortParameterName

获取或设置业务对象的名称,SelectMethod 参数使用此业务对象指定数据源排序支持的排序表达式。Gets or sets the name of the business object that the SelectMethod parameter used to specify a sort expression for data source sorting support.

SqlCacheDependency

获取或设置一个用分号分隔的字符串,指示用于 Microsoft SQL Server 缓存依赖项的数据库和表。Gets or sets a semicolon-delimited string that indicates which databases and tables to use for the Microsoft SQL Server cache dependency.

StartRowIndexParameterName

获取或设置数据检索方法参数的名称,该参数用于指示为数据源分页支持检索的第一条记录的标识符的值。Gets or sets the name of the data retrieval method parameter that is used to indicate the value of the identifier of the first record to retrieve for data source paging support.

TemplateControl

获取或设置对包含该控件的模板的引用。Gets or sets a reference to the template that contains this control.

(继承自 Control)
TemplateSourceDirectory

获取包含当前服务器控件的 PageUserControl 的虚拟目录。Gets the virtual directory of the Page or UserControl that contains the current server control.

(继承自 Control)
TypeName

获取或设置 ObjectDataSource 对象表示的类的名称。Gets or sets the name of the class that the ObjectDataSource object represents.

UniqueID

获取服务器控件的唯一的、以分层形式限定的标识符。Gets the unique, hierarchically qualified identifier for the server control.

(继承自 Control)
UpdateMethod

获取或设置由 ObjectDataSource 控件调用以更新数据的方法或函数的名称。Gets or sets the name of the method or function that the ObjectDataSource control invokes to update data.

UpdateParameters

获取参数集合,该集合包含由 UpdateMethod 属性指定的方法使用的参数。Gets the parameters collection that contains the parameters that are used by the method that is specified by the UpdateMethod property.

ValidateRequestMode

获取或设置指示控件是否检查来自浏览器的客户端输入是否具有潜在危险值的值。Gets or sets a value that indicates whether the control checks client input from the browser for potentially dangerous values.

(继承自 Control)
ViewState

获取状态信息的字典,这些信息使您可以在同一页的多个请求间保存和还原服务器控件的视图状态。Gets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page.

(继承自 Control)
ViewStateIgnoresCase

获取一个值,该值指示 StateBag 对象是否不区分大小写。Gets a value that indicates whether the StateBag object is case-insensitive.

(继承自 Control)
ViewStateMode

获取或设置此控件的视图状态模式。Gets or sets the view-state mode of this control.

(继承自 Control)
Visible

获取或设置一个值,该值指示是否以可视化方式显示控件。Gets or sets a value indicating whether the control is visually displayed.

(继承自 DataSourceControl)

方法

AddedControl(Control, Int32)

在子控件添加到 Controls 对象的 Control 集合后调用。Called after a child control is added to the Controls collection of the Control object.

(继承自 Control)
AddParsedSubObject(Object)

通知服务器控件,分析了一个元素(XML 或 HTML),并将该元素添加到服务器控件的 ControlCollection 对象中。Notifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's ControlCollection object.

(继承自 Control)
ApplyStyleSheetSkin(Page)

将页样式表中定义的样式属性应用于控件。Applies the style properties that are defined in the page style sheet to the control.

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

开始输出数据的设计时追踪。Begins design-time tracing of rendering data.

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

收集有关服务器控件的信息并将该信息发送到 Trace 属性,在启用页的跟踪功能时将显示该属性。Gathers information about the server control and delivers it to the Trace property to be displayed when tracing is enabled for the page.

(继承自 Control)
ClearCachedClientID()

将缓存的 ClientID 值设置为 nullSets the cached ClientID value to null.

(继承自 Control)
ClearChildControlState()

删除服务器控件的子控件的控件状态信息。Deletes the control-state information for the server control's child controls.

(继承自 Control)
ClearChildState()

删除服务器控件的所有子控件的视图状态和控件状态信息。Deletes the view-state and control-state information for all the server control's child controls.

(继承自 Control)
ClearChildViewState()

删除服务器控件的所有子控件的视图状态信息。Deletes the view-state information for all the server control's child controls.

(继承自 Control)
ClearEffectiveClientIDMode()

将当前控件实例和任何子控件的 ClientIDMode 属性设置为 InheritSets the ClientIDMode property of the current control instance and of any child controls to Inherit.

(继承自 Control)
CreateChildControls()

由 ASP.NET 页框架调用,以通知服务器控件在准备回发或呈现时使用基于撰写的实现来创建其所包含任何子控件。Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.

(继承自 Control)
CreateControlCollection()

创建用于存储子控件的集合。Creates a collection to store child controls.

(继承自 DataSourceControl)
DataBind()

将数据源绑定到调用的服务器控件及其所有子控件。Binds a data source to the invoked server control and all its child controls.

(继承自 Control)
DataBind(Boolean)

将数据源绑定到调用的服务器控件及其所有子控件,同时可以选择引发 DataBinding 事件。Binds a data source to the invoked server control and all its child controls with an option to raise the DataBinding event.

(继承自 Control)
DataBindChildren()

将数据源绑定到服务器控件的子控件。Binds a data source to the server control's child controls.

(继承自 Control)
Delete()

通过用 DeleteMethod 集合中的所有参数调用由 DeleteParameters 属性标识的方法,执行删除操作。Performs a delete operation by calling the method that is identified by the DeleteMethod property with any parameters that are in the DeleteParameters collection.

Dispose()

使服务器控件得以在从内存中释放之前执行最后的清理操作。Enables a server control to perform final clean up before it is released from memory.

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

结束输出数据的设计时追踪。Ends design-time tracing of rendering data.

(继承自 Control)
EnsureChildControls()

确定服务器控件是否包含子控件。Determines whether the server control contains child controls. 如果不包含,则创建子控件。If it does not, it creates child controls.

(继承自 Control)
EnsureID()

为尚未分配标识符的控件创建标识符。Creates an identifier for controls that do not have an identifier assigned.

(继承自 Control)
Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
FindControl(String)

在当前的命名容器中搜索带指定 id 参数的服务器控件。Searches the current naming container for a server control with the specified id parameter.

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

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

(继承自 Control)
Focus()

为控件设置输入焦点。Sets input focus to the control.

(继承自 DataSourceControl)
GetDesignModeState()

获取控件的设计时数据。Gets design-time data for a control.

(继承自 Control)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetRouteUrl(Object)

获取与一组路由参数对应的 URL。Gets the URL that corresponds to a set of route parameters.

(继承自 Control)
GetRouteUrl(RouteValueDictionary)

获取与一组路由参数对应的 URL。Gets the URL that corresponds to a set of route parameters.

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

获取与一组路由参数以及某个路由名称对应的 URL。Gets the URL that corresponds to a set of route parameters and a route name.

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

获取与一组路由参数以及某个路由名称对应的 URL。Gets the URL that corresponds to a set of route parameters and a route name.

(继承自 Control)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
GetUniqueIDRelativeTo(Control)

返回指定控件的 UniqueID 属性的前缀部分。Returns the prefixed portion of the UniqueID property of the specified control.

(继承自 Control)
GetView(String)

检索与数据源控件关联的命名数据源视图。Retrieves the named data source view that is associated with the data source control.

GetViewNames()

检索名称的集合,这些名称表示与 ObjectDataSource 对象关联的视图对象的列表。Retrieves a collection of names representing the list of view objects that are associated with the ObjectDataSource object.

HasControls()

确定服务器控件是否包含任何子控件。Determines if the server control contains any child controls.

(继承自 DataSourceControl)
HasEvents()

返回一个值,该值指示是否为控件或任何子控件注册事件。Returns a value indicating whether events are registered for the control or any child controls.

(继承自 Control)
Insert()

通过调用由 InsertMethod 属性标识的方法和 InsertParameters 集合中的所有参数,执行插入操作。Performs an insert operation by calling the method that is identified by the InsertMethod property and any parameters in the InsertParameters collection.

IsLiteralContent()

确定服务器控件是否只包含文字内容。Determines if the server control holds only literal content.

(继承自 Control)
LoadControlState(Object)

SaveControlState() 方法保存的上一个页请求还原控件状态信息。Restores control-state information from a previous page request that was saved by the SaveControlState() method.

(继承自 Control)
LoadViewState(Object)

加载以前保存的 ObjectDataSource 控件的视图状态。Loads the previously saved view state of the ObjectDataSource control.

MapPathSecure(String)

检索虚拟路径(绝对的或相对的)映射到的物理路径。Retrieves the physical path that a virtual path, either absolute or relative, maps to.

(继承自 Control)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

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

确定服务器控件的事件是否沿页的 UI 服务器控件层次结构向上传递。Determines whether the event for the server control is passed up the page's UI server control hierarchy.

(继承自 Control)
OnDataBinding(EventArgs)

引发 DataBinding 事件。Raises the DataBinding event.

(继承自 Control)
OnInit(EventArgs)

LoadComplete 事件处理程序添加到包含 ObjectDataSource 控件的页。Adds a LoadComplete event handler to the page that contains the ObjectDataSource control.

OnLoad(EventArgs)

引发 Load 事件。Raises the Load event.

(继承自 Control)
OnPreRender(EventArgs)

引发 PreRender 事件。Raises the PreRender event.

(继承自 Control)
OnUnload(EventArgs)

引发 Unload 事件。Raises the Unload event.

(继承自 Control)
OpenFile(String)

获取用于读取文件的 StreamGets a Stream used to read a file.

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

将所有事件源及其信息分配给控件的父级。Assigns any sources of the event and its information to the control's parent.

(继承自 Control)
RaiseDataSourceChangedEvent(EventArgs)

引发 DataSourceChanged 事件。Raises the DataSourceChanged event.

(继承自 DataSourceControl)
RemovedControl(Control)

Controls 对象的 Control 集合移除子控件后调用。Called after a child control is removed from the Controls collection of the Control object.

(继承自 Control)
Render(HtmlTextWriter)

将服务器控件内容发送到给定的 HtmlTextWriter 对象,该对象可编写将在客户端呈现的内容。Sends server control content to a provided HtmlTextWriter object, which writes the content to be rendered on the client.

(继承自 Control)
RenderChildren(HtmlTextWriter)

将服务器控件子级的内容输出到提供的 HtmlTextWriter 对象,此对象编写将在客户端呈现的内容。Outputs the content of a server control's children to a provided HtmlTextWriter object, which writes the content to be rendered on the client.

(继承自 Control)
RenderControl(HtmlTextWriter)

将服务器控件内容输出到所提供的 HtmlTextWriter 对象,如果启用了跟踪,则还将存储有关该控件的跟踪信息。Outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled.

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

使用提供的 HtmlTextWriter 对象将服务器控件内容输出到提供的 ControlAdapter 对象。Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object.

(继承自 Control)
ResolveAdapter()

获取负责呈现指定控件的控件适配器。Gets the control adapter responsible for rendering the specified control.

(继承自 Control)
ResolveClientUrl(String)

获取浏览器可以使用的 URL。Gets a URL that can be used by the browser.

(继承自 Control)
ResolveUrl(String)

将 URL 转换为在请求客户端可用的 URL。Converts a URL into one that is usable on the requesting client.

(继承自 Control)
SaveControlState()

保存将页面回发到服务器之后发生的所有服务器控件状态更改。Saves any server control state changes that have occurred since the time the page was posted back to the server.

(继承自 Control)
SaveViewState()

保存 ObjectDataSource 控件的状态。Saves the state of the ObjectDataSource control.

Select()

通过用 SelectMethod 集合中的参数调用由 SelectParameters 属性标识的方法,从基础数据存储中检索数据。Retrieves data from the underlying data storage by calling the method that is identified by the SelectMethod property with the parameters in the SelectParameters collection.

SetDesignModeState(IDictionary)

为控件设置设计时数据。Sets design-time data for a control.

(继承自 Control)
SetRenderMethodDelegate(RenderMethod)

分配事件处理程序委托,以将服务器控件及其内容呈现到父控件中。Assigns an event handler delegate to render the server control and its content into its parent control.

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

使用跟踪数据键和跟踪数据值,为呈现数据的设计时追踪设置跟踪数据。Sets trace data for design-time tracing of rendering data, using the trace data key and the trace data value.

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

使用跟踪对象、跟踪数据键和跟踪数据值,为呈现数据的设计时追踪设置跟踪数据。Sets trace data for design-time tracing of rendering data, using the traced object, the trace data key, and the trace data value.

(继承自 Control)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)
TrackViewState()

跟踪 ObjectDataSource 控件的视图状态更改,以便将这些更改存储到 StateBag 对象中。Tracks view-state changes to the ObjectDataSource control so that they can be stored in the StateBag object.

Update()

通过调用 UpdateMethod 属性标识的方法和 UpdateParameters 集合中的所有参数,执行更新操作。Performs an update operation by calling the method that is identified by the UpdateMethod property and any parameters that are in the UpdateParameters collection.

事件

DataBinding

当服务器控件绑定到数据源时发生。Occurs when the server control binds to a data source.

(继承自 Control)
Deleted

Delete() 操作完成时发生。Occurs when a Delete() operation has completed.

Deleting

Delete() 操作前发生。Occurs before a Delete() operation.

Disposed

当从内存释放服务器控件时发生,这是请求 ASP.NET 页时服务器控件生存期的最后阶段。Occurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested.

(继承自 Control)
Filtering

执行筛选操作前发生。Occurs before a filter operation.

Init

当服务器控件初始化时发生;初始化是控件生存期的第一步。Occurs when the server control is initialized, which is the first step in its lifecycle.

(继承自 Control)
Inserted

Insert() 操作完成时发生。Occurs when an Insert() operation has completed.

Inserting

Insert() 操作前发生。Occurs before an Insert() operation.

Load

当服务器控件加载到 Page 对象中时发生。Occurs when the server control is loaded into the Page object.

(继承自 Control)
ObjectCreated

在创建由 TypeName 属性标识的对象之后发生。Occurs after the object that is identified by the TypeName property is created.

ObjectCreating

在创建由 TypeName 属性标识的对象之前发生。Occurs before the object that is identified by the TypeName property is created.

ObjectDisposing

在丢弃由 TypeName 属性标识的对象之前发生。Occurs before the object that is identified by the TypeName property is discarded.

PreRender

在加载 Control 对象之后、呈现之前发生。Occurs after the Control object is loaded but prior to rendering.

(继承自 Control)
Selected

Select() 操作完成时发生。Occurs when a Select() operation has completed.

Selecting

Select() 操作前发生。Occurs before a Select() operation.

Unload

当服务器控件从内存中卸载时发生。Occurs when the server control is unloaded from memory.

(继承自 Control)
Updated

Update() 操作完成时发生。Occurs when an Update() operation has completed.

Updating

Update() 操作前发生。Occurs before an Update() operation.

显式接口实现

IControlBuilderAccessor.ControlBuilder

有关此成员的说明,请参阅 ControlBuilderFor a description of this member, see ControlBuilder.

(继承自 Control)
IControlDesignerAccessor.GetDesignModeState()

有关此成员的说明,请参阅 GetDesignModeState()For a description of this member, see GetDesignModeState().

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

有关此成员的说明,请参阅 SetDesignModeState(IDictionary)For a description of this member, see SetDesignModeState(IDictionary).

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

有关此成员的说明,请参阅 SetOwnerControl(Control)For a description of this member, see SetOwnerControl(Control).

(继承自 Control)
IControlDesignerAccessor.UserData

有关此成员的说明,请参阅 UserDataFor a description of this member, see UserData.

(继承自 Control)
IDataBindingsAccessor.DataBindings

有关此成员的说明,请参阅 DataBindingsFor a description of this member, see DataBindings.

(继承自 Control)
IDataBindingsAccessor.HasDataBindings

有关此成员的说明,请参阅 HasDataBindingsFor a description of this member, see HasDataBindings.

(继承自 Control)
IDataSource.DataSourceChanged

当数据源控件以某种影响数据绑定控件的方式发生更改时发生。Occurs when a data source control has changed in a way that affects data-bound controls.

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

获取与 DataSourceView 控件关联的指定 DataSourceControl 对象。Gets the named DataSourceView object associated with the DataSourceControl control. 有些数据源控件只支持一个视图,有些则支持多个视图。Some data source controls support only one view, while others support more than one.

(继承自 DataSourceControl)
IDataSource.GetViewNames()

获取名称的集合,表示与 DataSourceView 控件关联的 DataSourceControl 对象的列表。Gets a collection of names, representing the list of DataSourceView objects associated with the DataSourceControl control.

(继承自 DataSourceControl)
IExpressionsAccessor.Expressions

有关此成员的说明,请参阅 ExpressionsFor a description of this member, see Expressions.

(继承自 Control)
IExpressionsAccessor.HasExpressions

有关此成员的说明,请参阅 HasExpressionsFor a description of this member, see HasExpressions.

(继承自 Control)
IListSource.ContainsListCollection

指示数据源控件是否与一个或多个数据列表相关联。Indicates whether the data source control is associated with one or more lists of data.

(继承自 DataSourceControl)
IListSource.GetList()

获取可用作数据列表的源的数据源控件列表。Gets a list of data source controls that can be used as sources of lists of data.

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

有关此成员的说明,请参阅 AddParsedSubObject(Object)For a description of this member, see AddParsedSubObject(Object).

(继承自 Control)

扩展方法

FindDataSourceControl(Control)

返回与指定控件的数据控件关联的数据源。Returns the data source that is associated with the data control for the specified control.

FindFieldTemplate(Control, String)

返回指定控件的命名容器中指定列的字段模板。Returns the field template for the specified column in the specified control's naming container.

FindMetaTable(Control)

返回包含数据控件的元表对象。Returns the metatable object for the containing data control.

GetDefaultValues(IDataSource)

为指定数据源获取默认值的集合。Gets the collection of the default values for the specified data source.

GetMetaTable(IDataSource)

获取指定数据源对象中表的元数据。Gets the metadata for a table in the specified data source object.

TryGetMetaTable(IDataSource, MetaTable)

确定表元数据是否可用。Determines whether table metadata is available.

适用于

另请参阅