ObjectDataSourceDesigner クラス
アセンブリ: System.Design (system.design.dll 内)


ObjectDataSource コントロールは、データベースの削除、挿入、選択、および更新操作を実行するためにビジネス オブジェクトのメソッドを呼び出すデータ ソースを表します。
ビジュアル デザイナでソース ビューからデザイン ビューに切り替えると、ObjectDataSource コントロールを記述するマークアップのソース コードが解析され、コントロールのデザイン時バージョンがデザイン サーフェイスに作成されます。元のソース ビューに切り替えると、デザイン時コントロールがマークアップのソース コードに永続化され、Web ページのマークアップに反映されます。ObjectDataSourceDesigner クラスは、ビジュアル デザイナで ObjectDataSource コントロールをデザイン時に使用できるようにします。
ObjectDataSourceDesigner クラスのメンバは、次の機能を提供します。
-
CanConfigure プロパティは、データ ソースの構成ウィザードを表示できるかどうかを示します。CanRefreshSchema プロパティは、関連付けられている ObjectDataSource コントロールのスキーマをデザイン時に更新できるかどうかを示します。
-
SelectMethod プロパティは、Select 関数を実行するメソッドを指定します。TypeName プロパティは、関連付けられているコントロールにデータを提供するビジネス オブジェクトの型を指定します。
-
GetView メソッドは、指定した名前を持つデータ ソース ビューを返します。GetViewNames メソッドは、関連付けられている ObjectDataSource コントロールのデータ ソース ビュー名のリストを返します。RefreshSchema メソッドは、関連付けられているビジネス オブジェクトから Select メソッドのメタデータを抽出します。
-
Configure メソッドは、ビジュアル デザイナ画面にデータ ソースの構成ウィザードを表示します。PreFilterProperties メソッドは、関連付けられたコントロールからプロパティを削除したり、関連付けられたコントロールにプロパティを追加したりする場合に使用します。また、関連付けられたコントロールのプロパティをシャドウ プロパティにする場合にも使用します。

ObjectDataSourceDesigner クラスを拡張し、ObjectDataSource コントロールから派生したコントロールの外観と動作をデザイン時に変更するコード例を次に示します。
この例では、MyObjectDataSource コントロールを ObjectDataSource から派生させています。MyObjectDataSource は、ObjectDataSource コントロールのコピーです。この例では、さらに、ObjectDataSourceDesigner から MyObjectDataSourceDesigner クラスを派生させ、MyObjectDataSource コントロールの MyObjectDataSourceDesigner に DesignerAttribute 属性も適用しています。
MyObjectDataSourceDesigner は、PreFilterProperties メソッドをオーバーライドして、デザイン時に [プロパティ] グリッドに NamingContainer プロパティを表示します。
MyObjectDataSourceDesigner は、GetDesignTimeHtml メソッドをオーバーライドして、コントロールの種類および ID に加えて、TypeName プロパティおよび SelectMethod プロパティをプレースホルダに表示します。
Imports System Imports System.Web Imports System.Web.UI.WebControls Imports System.Web.UI.Design.WebControls Imports System.Collections Imports System.ComponentModel Imports System.Security.Permissions Namespace Examples.VB.WebControls.Design ' The MyObjectDataSource is a copy of the ObjectDataSource. <AspNetHostingPermission(SecurityAction.Demand, _ Level:=AspNetHostingPermissionLevel.Minimal)> _ <AspNetHostingPermission(SecurityAction.InheritanceDemand, _ Level:=AspNetHostingPermissionLevel.Minimal)> _ <Designer(GetType(Examples.VB.WebControls.Design. _ MyObjectDataSourceDesigner))> _ Public Class MyObjectDataSource Inherits ObjectDataSource End Class ' MyObjectDataSource ' Derive a designer that inherits from the ObjectDataSourceDesigner. <ReflectionPermission(SecurityAction.Demand, Flags:=ReflectionPermissionFlag.MemberAccess)> _ Public Class MyObjectDataSourceDesigner Inherits ObjectDataSourceDesigner ' Generate the design-time markup. Public Overrides Function GetDesignTimeHtml() As String ' Get a reference to the control or a copy of the control. Dim myODS As MyObjectDataSource = _ CType(ViewControl, MyObjectDataSource) Dim markup As String = _ CreatePlaceHolderDesignTimeHtml( _ "<b>TypeName</b> """ & myODS.TypeName & """<br />" & _ "<b>SelectMethod</b> """ & myODS.SelectMethod & """") Return markup End Function ' GetDesignTimeHtml ' Shadow the control properties with design-time properties. Protected Overrides Sub PreFilterProperties( _ ByVal properties As IDictionary) ' Call the base method first. MyBase.PreFilterProperties(properties) ' Make the NamingContainer visible in the Properties grid. Dim selectProp As PropertyDescriptor = _ CType(properties("NamingContainer"), PropertyDescriptor) properties("NamingContainer") = _ TypeDescriptor.CreateProperty(selectProp.ComponentType, _ selectProp, BrowsableAttribute.Yes) End Sub ' PreFilterProperties End Class ' MyObjectDataSourceDesigner End Namespace ' Examples.VB.WebControls.Design
using System; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.Design.WebControls; using System.Collections; using System.ComponentModel; using System.Security.Permissions; namespace Examples.CS.WebControls.Design { // The MyObjectDataSource is a copy of the ObjectDataSource. [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)] [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)] [Designer(typeof(Examples.CS.WebControls.Design. MyObjectDataSourceDesigner))] public class MyObjectDataSource : ObjectDataSource { } // MyObjectDataSource // Derive a designer that inherits from the ObjectDataSourceDesigner. [ReflectionPermission(SecurityAction.Demand, Flags=ReflectionPermissionFlag.MemberAccess)] public class MyObjectDataSourceDesigner : ObjectDataSourceDesigner { // Generate the design-time markup. public override string GetDesignTimeHtml() { // Get a reference to the control or a copy of the control. MyObjectDataSource myODS = (MyObjectDataSource)ViewControl; // Create a placeholder that displays the type of the business // object and the name of the Select method. string markup = CreatePlaceHolderDesignTimeHtml( "<b>TypeName</b> \"" + myODS.TypeName + "\"<br />" + "<b>SelectMethod</b> \"" + myODS.SelectMethod + "\"" ); return markup; } // GetDesignTimeHtml // Shadow the control properties with design-time properties. protected override void PreFilterProperties(IDictionary properties) { // Call the base method first. base.PreFilterProperties(properties); // Make the NamingContainer visible in the Properties grid. PropertyDescriptor selectProp = (PropertyDescriptor)properties["NamingContainer"]; properties["NamingContainer"] = TypeDescriptor.CreateProperty(selectProp.ComponentType, selectProp, BrowsableAttribute.Yes); } // PreFilterProperties } // MyObjectDataSourceDesigner } // Examples.CS.WebControls.Design

- SecurityPermission (ContentDesigner を使用するときにアンマネージ コードを呼び出すために必要なアクセス許可)。要求値 : Demand。アクセス許可値 : UnmanagedCode。

System.ComponentModel.Design.ComponentDesigner
System.Web.UI.Design.HtmlControlDesigner
System.Web.UI.Design.ControlDesigner
System.Web.UI.Design.DataSourceDesigner
System.Web.UI.Design.WebControls.ObjectDataSourceDesigner


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- ObjectDataSourceDesigner クラスのページへのリンク