ObjectDataSource 類別

定義

表示向多層 Web 應用程式架構中資料繫結控制項提供資料的商務物件 (Business Object)。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.

本節顯示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.

  • 類別會定義EmployeeLogic類別的GetAllEmployees方法所傳回的資料物件。 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功能, 例如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.

注意

SelectMethod、 、和InsertMethod static Shared屬性所識別的方法可以是實例方法或 (Visual Basic) 方法。 DeleteMethod UpdateMethodThe 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. 如果方法IEnumerable沒有傳回或DataSet物件, 則物件會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 ObjectDataSource 方法時,系結至的控制項,會自動呼叫屬性所DataBind指定的方法。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

如果ObjectDataSource SelectMethod 資料是DataTable以或物件的形式傳回, 則控制項可以篩選屬性所取出的資料。 DataSetThe 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. 當屬性設定為true時, ObjectDataSource會自動快取資料, 而屬性會設定為在捨棄快取之前,快取儲存資料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 在含有排序準則的SortParameterName 方法中,將屬性設定為SelectMethod參數的名稱。Set 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.
DeletingDeleting 將屬性設定為會刪除資料之商務物件方法或函數的名稱, 並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 將屬性設定為, 並CacheDuration根據您CacheExpirationPolicy要用於快取資料的快取行為, 將和屬性設為trueEnableCachingSet 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. 在這種情況下, 2009 年10月5日會TextBox在控制項中輸入為 5/10/2009, 但會被視為2009的5月10日。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控制項會與資料來源 view 類別相關聯。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, 而且一律會命名為DefaultViewObjectDataSourceThe 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. 您也可以將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.

使用 Entity FrameworkUsing the Entity Framework

您也可以將ObjectDataSource控制項與 Entity Framework 搭配使用。You can also use the ObjectDataSource control with the Entity Framework. 如需詳細資訊, 請參閱使用 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 值是否由 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

如果命名容器實作 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

取得控制項事件處理常式委派 (Delegate) 的清單。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

在網頁控制階層架構中取得伺服器控制項之父控制項的參考。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)

在子控制項加入 Control 物件的 Controls 集合後呼叫。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)

使用指定的 id 和有助於搜尋之 pathOffset 參數中所指定的整數,在目前的命名容器中搜尋伺服器控制項。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,此 URL 對應於一組路由參數及一個路由名稱。Gets the URL that corresponds to a set of route parameters and a route name.

(繼承來源 Control)
GetRouteUrl(String, RouteValueDictionary)

取得 URL,此 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)

Control 物件的 Controls 集合中移除子控制項之後呼叫。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.

適用於

另請參閱