ObjectDataSource ObjectDataSource ObjectDataSource ObjectDataSource Class

定义

表示为多层 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
继承
属性

示例

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

此部分显示ObjectDataSource .aspx 页中的标记, 并显示它使用的业务对象。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. 它包含GridView绑定ObjectDataSource到控件的控件。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:

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

  • 类定义由类的GetAllEmployees EmployeeLogic方法返回的数据对象。 NorthwindEmployeeThe 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. 有关如何安装 Northwind 商贸数据库的信息, 请参阅如何:安装示例数据库For information about how to install the Northwind Traders database, see How to: Install Sample Databases.

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不支持 visual 功能, 如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. 属性标识与一起使用的类ObjectDataSource的名称。 TypeNameThe 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.

备注

SelectMethodstatic SharedUpdateMethod、和属性标识的方法可以是实例方法或(在VisualBasic)方法。DeleteMethod InsertMethodThe methods that are identified by the SelectMethod, UpdateMethod, InsertMethod, and DeleteMethod properties can be instance methods or static (Shared in Visual Basic) methods. 如果static方法为ObjectDisposing (Shared在 Visual Basic 中), 则ObjectCreating不会创建业务对象的实例, 并且不会引发ObjectCreated、和事件。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.

每次调用ObjectDataSource 方法时,控件都将检索数据。SelectThe 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. 当调用SelectMethod 方法DataBind时, 绑定到的ObjectDataSource控件会自动调用由属性指定的方法。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. 设置属性是将ObjectDataSource控件绑定到数据绑定控件的建议方法。 DataSourceIDSetting 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

如果以DataSetSelectMethod ObjectDataSource 对象的形式返回数据,则控件DataTable可以筛选通过属性检索的数据。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.

缓存Caching

尽管不会跨多个请求保留业务对象的实例, 但它可以缓存调用SelectMethod由属性标识的方法的结果。 ObjectDataSourceAlthough 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. 当属性设置为ObjectDataSource true时, 将自动缓存数据, 并且属性设置为在放弃缓存之前缓存存储数据的秒数。CacheDuration EnableCachingThe 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. 控件允许缓存各种类型的数据, 但不应缓存保留无法共享以处理多个请求的资源或状态的对象 (例如打开SqlDataReader的对象), 因为对象的同一实例ObjectDataSource将用于为多个请求服务。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 将属性设置为业务对象方法的名称, 该方法选择数据, 并以编程方式或通过使用SelectParameters数据绑定控件包含集合中的任何必要参数。 SelectMethodSet 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 将属性设置为SelectMethod方法中携带排序条件的参数的名称。 SortParameterNameSet the SortParameterName property to the name of the parameter in the SelectMethod method that carries the sort criteria.
筛选Filtering 将属性设置为筛选表达式, 并选择性地将任何参数添加FilterParameters到集合, 以便在调用Select方法时筛选数据。 FilterExpressionSet 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属性指定的方法必须DataSet返回或DataTableThe method specified by the SelectMethod property must return a DataSet or DataTable.
分页Paging 如果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. 必须分别在MaximumRowsParameterNameStartRowIndexParameterName属性中设置这些参数的名称。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.
UpdatingUpdating 将属性设置为用于更新数据的业务对象方法的名称, 并UpdateParameters在集合中包含所有必需的参数。 UpdateMethodSet the UpdateMethod property to the name of the business object method that updates data, and include any necessary parameters in the UpdateParameters collection.
正在删除Deleting 将属性设置为用于删除数据的业务对象方法或函数的名称, 并DeleteParameters在集合中包含所有必需的参数。 DeleteMethodSet 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 将属性设置为业务对象方法的名称或插入数据的函数, 并InsertParameters在集合中包含所有必要的参数。 InsertMethodSet 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.
缓存Caching 将属性设置为true, CacheDuration将和CacheExpirationPolicy属性设置为缓存数据所需的缓存行为。 EnableCachingSet 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 将TextBox在控件中作为5/10/2009 输入, 但会解释为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. 尽管控件是页开发人员用来处理数据的接口ObjectDataSourceView , 但该类是数据绑定控件所使用的接口。 ObjectDataSourceWhile 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. 控件仅有一个关联ObjectDataSourceView的, 并且始终命名DefaultView为。 ObjectDataSourceThe ObjectDataSource control has only one associated ObjectDataSourceView, and it is always named DefaultView. 当对象由方法公开时, 它的许多属性和方法会直接由ObjectDataSource控件包装和公开。 GetView ObjectDataSourceViewWhile 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. 还将SelectMethodUpdateMethodInsertMethod和方法设置为数据上下文类中执行相应操作的方法。DeleteMethodYou 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() ObjectDataSource() ObjectDataSource()

初始化 ObjectDataSource 类的新实例。Initializes a new instance of the ObjectDataSource class.

ObjectDataSource(String, String) ObjectDataSource(String, String) ObjectDataSource(String, String) ObjectDataSource(String, String)

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

属性

Adapter Adapter Adapter Adapter

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

(Inherited from Control)
AppRelativeTemplateSourceDirectory AppRelativeTemplateSourceDirectory AppRelativeTemplateSourceDirectory AppRelativeTemplateSourceDirectory

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

(Inherited from Control)
BindingContainer BindingContainer BindingContainer BindingContainer

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

(Inherited from Control)
CacheDuration CacheDuration CacheDuration CacheDuration

获取或设置以秒为单位的一段时间,数据源控件就在这段时间内缓存 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 CacheExpirationPolicy CacheExpirationPolicy CacheExpirationPolicy

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

CacheKeyDependency CacheKeyDependency CacheKeyDependency CacheKeyDependency

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

ChildControlsCreated ChildControlsCreated ChildControlsCreated ChildControlsCreated

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

(Inherited from Control)
ClientID ClientID ClientID ClientID

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

(Inherited from DataSourceControl)
ClientIDMode ClientIDMode ClientIDMode ClientIDMode

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

(Inherited from DataSourceControl)
ClientIDSeparator ClientIDSeparator ClientIDSeparator ClientIDSeparator

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

(Inherited from Control)
ConflictDetection ConflictDetection ConflictDetection ConflictDetection

获取或设置一个值,该值确定是仅将新值传递给 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 Context Context Context

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

(Inherited from Control)
Controls Controls Controls Controls

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

(Inherited from DataSourceControl)
ConvertNullToDBNull ConvertNullToDBNull ConvertNullToDBNull ConvertNullToDBNull

获取或设置一个值,该值指示传递给更新、插入或删除操作的 Parameter 值是否由 Value 控件自动从 null 转换为 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 DataItemContainer DataItemContainer DataItemContainer

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

(Inherited from Control)
DataKeysContainer DataKeysContainer DataKeysContainer DataKeysContainer

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

(Inherited from Control)
DataObjectTypeName DataObjectTypeName DataObjectTypeName 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 DeleteMethod DeleteMethod DeleteMethod

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

DeleteParameters DeleteParameters DeleteParameters DeleteParameters

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

DesignMode DesignMode DesignMode DesignMode

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

(Inherited from Control)
EnableCaching EnableCaching EnableCaching EnableCaching

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

EnablePaging EnablePaging EnablePaging EnablePaging

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

EnableTheming EnableTheming EnableTheming EnableTheming

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

(Inherited from DataSourceControl)
EnableViewState EnableViewState EnableViewState EnableViewState

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

(Inherited from Control)
Events Events Events Events

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

(Inherited from Control)
FilterExpression FilterExpression FilterExpression FilterExpression

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

FilterParameters FilterParameters FilterParameters FilterParameters

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

HasChildViewState HasChildViewState HasChildViewState HasChildViewState

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

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

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

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

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

(Inherited from Control)
ID ID ID ID

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

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

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

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

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

(Inherited from Control)
IdSeparator IdSeparator IdSeparator IdSeparator

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

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

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

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

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

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

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

(Inherited from DataSourceControl)
InsertMethod InsertMethod InsertMethod InsertMethod

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

InsertParameters InsertParameters InsertParameters InsertParameters

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

IsChildControlStateCleared IsChildControlStateCleared IsChildControlStateCleared IsChildControlStateCleared

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

(Inherited from Control)
IsTrackingViewState IsTrackingViewState IsTrackingViewState IsTrackingViewState

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

(Inherited from Control)
IsViewStateEnabled IsViewStateEnabled IsViewStateEnabled IsViewStateEnabled

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

(Inherited from Control)
LoadViewStateByID LoadViewStateByID LoadViewStateByID LoadViewStateByID

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

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

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

(Inherited from Control)
OldValuesParameterFormatString OldValuesParameterFormatString OldValuesParameterFormatString OldValuesParameterFormatString

获取或设置一个格式字符串,该字符串应用于传递给 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 Page Page

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

(Inherited from Control)
Parent Parent Parent Parent

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

(Inherited from Control)
ParsingCulture ParsingCulture ParsingCulture 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 RenderingCompatibility RenderingCompatibility RenderingCompatibility

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

(Inherited from Control)
SelectCountMethod SelectCountMethod SelectCountMethod SelectCountMethod

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

SelectMethod SelectMethod SelectMethod SelectMethod

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

SelectParameters SelectParameters SelectParameters SelectParameters

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

Site Site Site Site

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

(Inherited from Control)
SkinID SkinID SkinID SkinID

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

(Inherited from DataSourceControl)
SortParameterName SortParameterName SortParameterName SortParameterName

获取或设置业务对象的名称,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 SqlCacheDependency SqlCacheDependency SqlCacheDependency

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

StartRowIndexParameterName StartRowIndexParameterName StartRowIndexParameterName 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 TemplateControl TemplateControl TemplateControl

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

(Inherited from Control)
TemplateSourceDirectory TemplateSourceDirectory TemplateSourceDirectory TemplateSourceDirectory

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

(Inherited from Control)
TypeName TypeName TypeName TypeName

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

UniqueID UniqueID UniqueID UniqueID

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

(Inherited from Control)
UpdateMethod UpdateMethod UpdateMethod UpdateMethod

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

UpdateParameters UpdateParameters UpdateParameters UpdateParameters

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

ValidateRequestMode ValidateRequestMode ValidateRequestMode ValidateRequestMode

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

(Inherited from Control)
ViewState ViewState ViewState ViewState

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

(Inherited from Control)
ViewStateIgnoresCase ViewStateIgnoresCase ViewStateIgnoresCase ViewStateIgnoresCase

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

(Inherited from Control)
ViewStateMode ViewStateMode ViewStateMode ViewStateMode

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

(Inherited from Control)
Visible Visible Visible Visible

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

(Inherited from DataSourceControl)

方法

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

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

(Inherited from Control)
AddParsedSubObject(Object) AddParsedSubObject(Object) AddParsedSubObject(Object) AddParsedSubObject(Object)

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

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

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

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

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

(Inherited from Control)
BuildProfileTree(String, Boolean) BuildProfileTree(String, Boolean) BuildProfileTree(String, Boolean) BuildProfileTree(String, Boolean)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(Inherited from DataSourceControl)
DataBind() DataBind() DataBind() DataBind()

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

(Inherited from Control)
DataBind(Boolean) DataBind(Boolean) DataBind(Boolean) DataBind(Boolean)

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

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

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

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

通过用 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() Dispose() Dispose() Dispose()

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

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

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

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

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

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

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

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

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

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

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

(Inherited from DataSourceControl)
FindControl(String, Int32) FindControl(String, Int32) FindControl(String, Int32) FindControl(String, Int32)

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

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

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

(Inherited from DataSourceControl)
GetDesignModeState() GetDesignModeState() GetDesignModeState() GetDesignModeState()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

通过调用由 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() IsLiteralContent() IsLiteralContent() IsLiteralContent()

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

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

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

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

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

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

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

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

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

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

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

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

引发 DataBinding 事件。Raises the DataBinding event.

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

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

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

引发 Load 事件。Raises the Load event.

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

引发 PreRender 事件。Raises the PreRender event.

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

引发 Unload 事件。Raises the Unload event.

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

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

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

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

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

引发 DataSourceChanged 事件。Raises the DataSourceChanged event.

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

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

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

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

(Inherited from Control)
RenderChildren(HtmlTextWriter) RenderChildren(HtmlTextWriter) RenderChildren(HtmlTextWriter) RenderChildren(HtmlTextWriter)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Select() Select() Select() 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) SetDesignModeState(IDictionary) SetDesignModeState(IDictionary) SetDesignModeState(IDictionary)

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

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

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

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

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

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

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

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

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

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

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

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

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

(Inherited from Control)
Deleted Deleted Deleted Deleted

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

Deleting Deleting Deleting Deleting

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

Disposed Disposed Disposed Disposed

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

(Inherited from Control)
Filtering Filtering Filtering Filtering

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

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

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

(Inherited from DataSourceControl)
Init Init Init Init

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

(Inherited from Control)
Inserted Inserted Inserted Inserted

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

Inserting Inserting Inserting Inserting

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

Load Load Load Load

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

(Inherited from Control)
ObjectCreated ObjectCreated ObjectCreated ObjectCreated

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

ObjectCreating ObjectCreating ObjectCreating ObjectCreating

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

ObjectDisposing ObjectDisposing ObjectDisposing ObjectDisposing

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

PreRender PreRender PreRender PreRender

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

(Inherited from Control)
Selected Selected Selected Selected

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

Selecting Selecting Selecting Selecting

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

Unload Unload Unload Unload

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

(Inherited from Control)
Updated Updated Updated Updated

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

Updating Updating Updating Updating

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

显式界面实现

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(Inherited from Control)

扩展方法

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

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

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

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

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

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

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

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

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

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

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

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

适用于

另请参阅