ObjectDataSource イベント

名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。 ( Control から継承されます。) |
![]() | Deleted | Delete 操作の完了時に発生します。 |
![]() | Deleting | Delete 操作の前に発生します。 |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。 ( Control から継承されます。) |
![]() | Filtering | フィルタ操作の前に発生します。 |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。 ( Control から継承されます。) |
![]() | Inserted | Insert 操作の完了時に発生します。 |
![]() | Inserting | Insert 操作の前に発生します。 |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。 ( Control から継承されます。) |
![]() | ObjectCreated | TypeName プロパティで識別されるオブジェクトが作成された後に発生します。 |
![]() | ObjectCreating | TypeName プロパティで識別されるオブジェクトが作成される前に発生します。 |
![]() | ObjectDisposing | TypeName プロパティで識別されるオブジェクトが破棄される前に発生します。 |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。 ( Control から継承されます。) |
![]() | Selected | Select 操作の完了時に発生します。 |
![]() | Selecting | Select 操作の前に発生します。 |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。 ( Control から継承されます。) |
![]() | Updated | Update 操作の完了時に発生します。 |
![]() | Updating | Update 操作の前に発生します。 |

関連項目
ObjectDataSource クラスSystem.Web.UI.WebControls 名前空間
IDataSource
DataSourceControl
ObjectDataSourceView
ObjectDataSource クラス
アセンブリ: System.Web (system.web.dll 内)

Public Class ObjectDataSource Inherits DataSourceControl
public class ObjectDataSource : DataSourceControl
public class ObjectDataSource extends DataSourceControl
public class ObjectDataSource extends DataSourceControl

ObjectDataSource は、データ バインド コントロールに対してデータ バインディング関連の中間層オブジェクトまたはデータ インターフェイス オブジェクトを表す ASP.NET データ ソース コントロールです。ObjectDataSource をデータ バインド コントロールと組み合わせて使用すると、コードをほとんどまたはまったく必要とせずに、Web ページでデータの表示、編集、並べ替えを行うことができます。
アプリケーションのごく一般的なデザイン方法は、プレゼンテーション層をビジネス ロジックから分離し、ビジネス ロジックをビジネス オブジェクトにカプセル化する方法です。これらのビジネス オブジェクトは、プレゼンテーション層とデータ層を明確に区別する層を形成します。したがって、3 階層アプリケーション アーキテクチャを実現します。ObjectDataSource コントロールを使用すると、開発者は 3 階層アプリケーション アーキテクチャを維持しながら、ASP.NET データ ソース コントロールを使用できます。
ObjectDataSource コントロールは、リフレクションを使用してビジネス オブジェクトのインスタンスを作成し、作成したインスタンスに対してメソッドを呼び出してデータを更新、挿入、および削除します。TypeName プロパティは、ObjectDataSource が使用するクラスの名前を識別します。ObjectDataSource コントロールは、メソッドを呼び出すたびにクラスのインスタンスを作成し、破棄します。つまり、このコントロールは、Web 要求の有効期間中、メモリ内にオブジェクトを保持しません。使用するビジネス オブジェクトに多数のリソースが必要な場合、この点を十分に考慮しないと、作成と破棄に負荷がかかります。負荷のかかるオブジェクトの使用はデザイン上の最適な選択とはいえませんが、ObjectCreating、ObjectCreated、ObjectDisposing の各イベントを使用することで、オブジェクトの有効期間を制御できます。
![]() |
---|
SelectMethod、UpdateMethod、InsertMethod、DeleteMethod の各プロパティで識別されるメソッドには、インスタンス メソッドまたは static (Visual Basic では Shared) メソッドを指定できます。メソッドが static (Visual Basic では Shared) の場合、ビジネス オブジェクトのインスタンスは作成されず、ObjectCreating、ObjectCreated、ObjectDisposing の各イベントは発生しません。 |
ビジネス オブジェクトからデータを取得するには、データを取得するメソッドの名前で SelectMethod プロパティを設定します。メソッドが IEnumerable オブジェクトまたは DataSet オブジェクトを返さない場合、オブジェクトはランタイムによって IEnumerable コレクションにラップされます。メソッド シグネチャにパラメータが含まれている場合は、Parameter オブジェクトを SelectParameters コレクションに追加でき、さらにこれらのオブジェクトを、SelectMethod メソッドで指定されたメソッドに渡す値にバインドできます。ObjectDataSource でパラメータを使用するには、パラメータがメソッド シグネチャのパラメータの名前と型に一致する必要があります。
ObjectDataSource コントロールは、Select メソッドが呼び出されるたびにデータを取得します。このメソッドを使用すると、SelectMethod プロパティで指定されたメソッドにプログラムによってアクセスできます。SelectMethod プロパティで指定されたメソッドは、DataBind メソッドの呼び出し時に、ObjectDataSource にバインドされたコントロールによって自動的に呼び出されます。データ バインド コントロールの DataSourceID プロパティを設定すると、コントロールは必要に応じてデータ ソースのデータに自動的にバインドされます。ObjectDataSource コントロールをデータ バインド コントロールにバインドする場合は、DataSourceID プロパティを設定することをお勧めします。DataSource プロパティを設定することもできますが、その場合はデータ バインド コントロールの DataBind メソッドを明示的に呼び出す必要があります。データを取得するために、Select メソッドをプログラムによっていつでも呼び出すことができます。
データ バインド コントロールをデータ ソース コントロールにバインドする方法の詳細については、「データ ソース コントロールによるデータへのバインド」を参照してください。
ObjectDataSource コントロールが使用するビジネス オブジェクトの機能に応じて、更新、挿入、削除などのデータ操作を実行できます。これらのデータ操作を実行するには、実行する操作に対して適切なメソッド名と関連するパラメータを設定します。たとえば、更新操作の場合、UpdateMethod プロパティを、更新を実行するビジネス オブジェクト メソッドの名前に設定し、必要なパラメータを UpdateParameters コレクションに追加します。ObjectDataSource コントロールがデータ バインド コントロールに関連付けられている場合、パラメータはそのデータ バインド コントロールによって追加されます。この場合、メソッドのパラメータ名とデータ バインド コントロールのフィールド名を必ず一致させる必要があります。Update メソッドがコードから明示的に呼び出されるか、データ バインド コントロールから自動的に呼び出されると、更新が実行されます。Delete 操作および Insert 操作の場合も、同じ一般的なパターンに従います。ビジネス オブジェクトは、これらのデータ操作をバッチ処理ではなく、一度に 1 レコードずつ実行することを前提としています。
データが DataSet、DataView、DataTable の各オブジェクトとして返される場合、ObjectDataSource コントロールは、SelectMethod プロパティによって取得したデータをフィルタ処理できます。ObjectDataSource コントロールを使用すると、データのすべての型をキャッシュできます。ただし、オブジェクトのこの同じインスタンスは、複数の要求を処理するために使用されるため、複数の要求を処理する際に共有できないリソースや状態を保持しているオブジェクト (開いた SqlDataReader オブジェクトなど) はキャッシュしないでください。書式指定文字列の構文を使用して、FilterExpression プロパティをフィルタ式に設定し、式の値を FilterParameters コレクションの指定されたパラメータにバインドできます。
ObjectDataSource は、ビジネス オブジェクトのインスタンスを複数の要求にわたって保持はしませんが、SelectMethod メソッドの結果をキャッシュできます。データがキャッシュされている間、Select メソッドの以降の呼び出しは、ビジネス オブジェクトを作成し、リフレクションを使用してそのビジネス オブジェクトの SelectMethod を呼び出す代わりに、キャッシュ データを返します。オブジェクトを作成し、データ メソッドを呼び出すと Web サーバー上のメモリが消費されますが、キャッシュを利用することでこれを回避できます。つまり、これは適切なトレードオフといえます。EnableCaching プロパティを true に設定し、CacheDuration プロパティをキャッシュが破棄されるまでの秒数、つまり、キャッシュにデータが格納される秒数に設定すると、ObjectDataSource はデータを自動的にキャッシュします。また、CacheExpirationPolicy プロパティやオプションの SqlCacheDependency プロパティを指定することもできます。
ObjectDataSource コントロールの機能を次の表に示します。
すべてのデータ ソース コントロールと同様に、ObjectDataSource コントロールはデータ ソース ビュー クラスに関連付けられています。ObjectDataSource コントロールは、ページ開発者がデータを処理するために使用するインターフェイスであり、ObjectDataSourceView クラスはデータ バインド コントロールが使用するインターフェイスです。また、ObjectDataSourceView クラスは、データ ソース コントロールの機能を記述し、実際の処理を実行します。ObjectDataSource コントロールには、ObjectDataSourceView が 1 つだけ関連付けられており、常に DefaultView という名前になります。ObjectDataSourceView オブジェクトは GetView メソッドによって公開され、そのプロパティとメソッドの多くは、ObjectDataSource コントロールによってラップされ、直接公開されます。背後では、データの取得、挿入、更新、削除、フィルタ処理、並べ替えなど、すべてのデータ操作を ObjectDataSourceView オブジェクトが実行します。詳細については、「ObjectDataSourceView」を参照してください。
ObjectDataSource コントロールは視覚的に表示されません。このコントロールは、宣言によって作成できるようにコントロールとして実装されます。また、オプションで状態管理に関与させることもできます。したがって、ObjectDataSource は、EnableTheming プロパティや SkinID プロパティなどの表示機能をサポートしていません。

このセクションには、2 つのコード例が含まれています。1 つ目のコード例では、GridView コントロールが Web フォームの ObjectDataSource オブジェクトを使用してデータを表示する方法を示します。2 つ目のコード例では、このコード例と ObjectDataSource の他の多くのコード例で使用する中間層ビジネス オブジェクトの例を示します。
GridView コントロールが Web フォームの ObjectDataSource コントロールを使用してデータを表示する方法を次のコード例に示します。ObjectDataSource は、TypeName プロパティでビジネス オブジェクトの部分修飾クラス名または完全修飾クラス名を識別し、SelectMethod プロパティでデータを取得するために呼び出されるビジネス オブジェクト メソッドを識別します。実行時にオブジェクトが作成され、メソッドはリフレクションを使用して呼び出されます。GridView コントロールは、SelectMethod によって返された IEnumerable コレクションに対して列挙処理を実行し、データを表示します。
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB" Assembly="Samples.AspNet.VB" %> <%@ Page language="vb" %> <html> <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>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS" Assembly="Samples.AspNet.CS" %> <%@ Page language="c#" %> <html> <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.JSL" Assembly="Samples.AspNet.JSL" %> <%@ Page language="VJ#" %> <html> <head> <title>ObjectDataSource - VJ# 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.JSL.EmployeeLogic" /> </form> </body> </html>
このコード例と ObjectDataSource の他の多くのコード例で使用する中間層ビジネス オブジェクトの例を次のコード例に示します。このコード例は、次の 2 つのビジネス クラスで構成されます。
便宜上、追加の NorthwindDataException クラスが提供されています。
これらのサンプル クラスは、Northwind Traders データベース (Microsoft SQL Server および Microsoft Access に付属) で動作します。実際に動作させるためには、これらのクラスをコンパイルし、提供された Web フォームのコード例と組み合わせて使用する必要があります。
この例は、ビジネス オブジェクトが ObjectDataSource コントロールとやり取りする最も一般的な方法の 1 つに従って、これをわかりやすく示すようにデザインされています。これがデザインの推奨例ではありません。一部の例では、EmployeeLogic クラスまたは NorthwindEmployee クラスにメソッドが追加されています。また、このクラスのセットに変更を加え、基本概念を示している例もあります。
Imports System 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 'UpdateEmployeeInfo Public Shared Sub DeleteEmployee(ne As NorthwindEmployee) End Sub 'DeleteEmployee End Class 'EmployeeLogic Public Class NorthwindEmployee Public Sub New() ID = DBNull.Value aLastName = "" aFirstName = "" aTitle = "" titleOfCourtesy = "" reportsTo = - 1 End Sub 'New 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 'New 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 'NorthwindEmployee Friend Class NorthwindDataException Inherits Exception Public Sub New(msg As String) MyBase.New(msg) End Sub 'New End Class 'NorthwindDataException End Namespace
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) { } } }
package Samples.AspNet.JSL; import System.*; import System.Collections.*; import System.Collections.Specialized.*; import System.Configuration.*; import System.Data.*; import System.Data.SqlClient.*; import System.Web.UI.*; import 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() throws NorthwindDataException, SqlException { ArrayList al = new ArrayList(); ConnectionStringSettings cts = ConfigurationManager.get_ConnectionStrings().get_Item("NorthwindConnection"); SqlDataSource sds = new SqlDataSource(cts.get_ConnectionString(), "SELECT EmployeeID FROM Employees"); try { IEnumerable ids = sds.Select(DataSourceSelectArguments.get_Empty()); // Iterate through the Enumeration and create a // NorthwindEmployee object for each id. IEnumerator enumerator = ids.GetEnumerator(); while (enumerator.MoveNext()) { // The IEnumerable contains DataRowView objects. DataRowView row = (DataRowView)enumerator.get_Current(); String id = row.get_Item("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; } //GetAllEmployees public static NorthwindEmployee GetEmployee(Object anId) throws NorthwindDataException, SqlException { return new NorthwindEmployee(anId); } //GetEmployee public static void UpdateEmployeeInfo(NorthwindEmployee ne) throws NorthwindDataException, SqlException { boolean retval = ne.Save(); if (!retval) { throw new NorthwindDataException("UpdateEmployee failed."); } } //UpdateEmployeeInfo public static void DeleteEmployee(NorthwindEmployee ne) { } //DeleteEmployee } //EmployeeLogic public class NorthwindEmployee { public NorthwindEmployee() { id = DBNull.Value; lastName = ""; firstName = ""; title = ""; titleOfCourtesy = ""; reportsTo = -1; } //NorthwindEmployee public NorthwindEmployee(Object anId) throws NorthwindDataException, SqlException { this.id = anId; ConnectionStringSettings cts = ConfigurationManager.get_ConnectionStrings().get_Item("NorthwindConnection"); SqlConnection conn = new SqlConnection(cts.get_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.get_Parameters().Add(new SqlParameter("@empId", SqlDbType.Int)). set_Value((Int32)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.get_Item("FirstName").ToString(); this.lastName = sdr.get_Item("LastName").ToString(); this.title = sdr.get_Item("Title").ToString(); this.titleOfCourtesy = sdr.get_Item("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 exp) { // Log an event in the Application Event Log. throw exp; } } } //NorthwindEmployee private Object id; private String lastName; /** @property */ public String get_LastName() { return lastName; } //get_LastName /** @property */ public void set_LastName(String value) { lastName = value; } //set_LastName private String firstName; /** @property */ public String get_FirstName() { return firstName; } //get_FirstName /** @property */ public void set_FirstName(String value) { firstName = value; } //set_FirstName private String title; /** @property */ public String get_Title() { return title; } //get_Title /** @property */ public void set_Title(String value) { title = value; } //set_Title private String titleOfCourtesy; /** @property */ public String get_Courtesy() { return titleOfCourtesy; } //get_Courtesy /** @property */ public void set_Courtesy(String value) { titleOfCourtesy = value; } //set_Courtesy private int reportsTo; /** @property */ public int get_Supervisor() { return reportsTo; } //get_Supervisor /** @property */ public void set_Supervisor(int value) { reportsTo = value; } //set_Supervisor public boolean Save() { return true; } //Save } //NorthwindEmployee public class NorthwindDataException extends System.Exception { public NorthwindDataException(String msg) { super(msg); } //NorthwindDataException } //NorthwindDataException


System.Web.UI.Control
System.Web.UI.DataSourceControl
System.Web.UI.WebControls.ObjectDataSource


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ObjectDataSource メンバ
System.Web.UI.WebControls 名前空間
IDataSource
DataSourceControl
ObjectDataSourceView
ObjectDataSource コンストラクタ ()
アセンブリ: System.Web (system.web.dll 内)


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ObjectDataSource コンストラクタ (String, String)
アセンブリ: System.Web (system.web.dll 内)

Dim typeName As String Dim selectMethod As String Dim instance As New ObjectDataSource(typeName, selectMethod)

typeName パラメータの値には、Bin ディレクトリまたは App_Code ディレクトリにあるコードの部分修飾型、またはグローバル アセンブリ キャッシュに登録されたコードの完全修飾型名を指定できます。グローバル アセンブリ キャッシュを使用する場合、Machine.config 構成ファイルまたは Web.config 構成ファイルの assemblies セクションに適切な参照を追加する必要があります。

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ObjectDataSource コンストラクタ

名前 | 説明 |
---|---|
ObjectDataSource () | ObjectDataSource クラスの新しいインスタンスを初期化します。 |
ObjectDataSource (String, String) | 型名とデータ取得メソッド名を指定して、ObjectDataSource クラスの新しいインスタンスを初期化します。 |

ObjectDataSource プロパティ



関連項目
ObjectDataSource クラスSystem.Web.UI.WebControls 名前空間
IDataSource
DataSourceControl
ObjectDataSourceView
ObjectDataSource メソッド



関連項目
ObjectDataSource クラスSystem.Web.UI.WebControls 名前空間
IDataSource
DataSourceControl
ObjectDataSourceView
ObjectDataSource メンバ
多階層 Web アプリケーション アーキテクチャで、データ バインド コントロールにデータを提供するビジネス オブジェクトを表します。
ObjectDataSource データ型で公開されるメンバを以下の表に示します。






名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。(Control から継承されます。) |
![]() | Deleted | Delete 操作の完了時に発生します。 |
![]() | Deleting | Delete 操作の前に発生します。 |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。(Control から継承されます。) |
![]() | Filtering | フィルタ操作の前に発生します。 |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。(Control から継承されます。) |
![]() | Inserted | Insert 操作の完了時に発生します。 |
![]() | Inserting | Insert 操作の前に発生します。 |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。(Control から継承されます。) |
![]() | ObjectCreated | TypeName プロパティで識別されるオブジェクトが作成された後に発生します。 |
![]() | ObjectCreating | TypeName プロパティで識別されるオブジェクトが作成される前に発生します。 |
![]() | ObjectDisposing | TypeName プロパティで識別されるオブジェクトが破棄される前に発生します。 |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。(Control から継承されます。) |
![]() | Selected | Select 操作の完了時に発生します。 |
![]() | Selecting | Select 操作の前に発生します。 |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。(Control から継承されます。) |
![]() | Updated | Update 操作の完了時に発生します。 |
![]() | Updating | Update 操作の前に発生します。 |

関連項目
ObjectDataSource クラスSystem.Web.UI.WebControls 名前空間
IDataSource
DataSourceControl
ObjectDataSourceView
Weblioに収録されているすべての辞書からObjectDataSourceを検索する場合は、下記のリンクをクリックしてください。

- ObjectDataSourceのページへのリンク