-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
ObjectDataSourceDisposingEventArgs.xml
137 lines (119 loc) · 15.1 KB
/
ObjectDataSourceDisposingEventArgs.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<Type Name="ObjectDataSourceDisposingEventArgs" FullName="System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs">
<TypeSignature Language="C#" Value="public class ObjectDataSourceDisposingEventArgs : System.ComponentModel.CancelEventArgs" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit ObjectDataSourceDisposingEventArgs extends System.ComponentModel.CancelEventArgs" />
<TypeSignature Language="DocId" Value="T:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs" />
<TypeSignature Language="VB.NET" Value="Public Class ObjectDataSourceDisposingEventArgs
Inherits CancelEventArgs" />
<TypeSignature Language="F#" Value="type ObjectDataSourceDisposingEventArgs = class
 inherit CancelEventArgs" />
<TypeSignature Language="C++ CLI" Value="public ref class ObjectDataSourceDisposingEventArgs : System::ComponentModel::CancelEventArgs" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.ComponentModel.CancelEventArgs</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Provides data for the <see cref="E:System.Web.UI.WebControls.ObjectDataSource.ObjectDisposing" /> event of the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs> class is used in the <xref:System.Web.UI.WebControls.ObjectDataSourceView.OnObjectDisposing%2A> method to provide access to the business object instance after any data operations that are using the <xref:System.Web.UI.WebControls.ObjectDataSource> control and business object are performed, but before the business object is destroyed. The business object is accessed using the <xref:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs.ObjectInstance%2A> property. By adding a delegate to handle the <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectDisposing> event, you can access any publicly exposed members of the business object to perform any final work or clean up.
The <xref:System.Web.UI.WebControls.ObjectDataSourceView.OnObjectDisposing%2A> method is not called by the <xref:System.Web.UI.WebControls.ObjectDataSource> control, if the method that performs data operations is a `static` method. No business object instance is created when the method is static.
The <xref:System.Web.UI.WebControls.ObjectDataSource> control exposes many events that you can handle to work with the underlying business object at various times in its lifecycle. The following table lists the events and the associated <xref:System.EventArgs> classes and event handler delegates.
|Event|EventArgs|EventHandler|
|-----------|---------------|------------------|
|<xref:System.Web.UI.WebControls.ObjectDataSource.ObjectCreating>.<br /><br /> Occurs immediately before the instance of the business object is created.|<xref:System.Web.UI.WebControls.ObjectDataSourceEventArgs>|<xref:System.Web.UI.WebControls.ObjectDataSourceObjectEventHandler>|
|<xref:System.Web.UI.WebControls.ObjectDataSource.ObjectCreated>.<br /><br /> Occurs immediately after the instance of the business object is created.|<xref:System.Web.UI.WebControls.ObjectDataSourceEventArgs>|<xref:System.Web.UI.WebControls.ObjectDataSourceObjectEventHandler>|
|<xref:System.Web.UI.WebControls.ObjectDataSource.Selecting>.<br /><br /> Occurs before the data is retrieved.|<xref:System.Web.UI.WebControls.ObjectDataSourceSelectingEventArgs>|<xref:System.Web.UI.WebControls.ObjectDataSourceSelectingEventHandler>|
|<xref:System.Web.UI.WebControls.ObjectDataSource.Inserting>, <xref:System.Web.UI.WebControls.ObjectDataSource.Updating>, and <xref:System.Web.UI.WebControls.ObjectDataSource.Deleting>.<br /><br /> Occur before an insert, update, or delete operation is performed.|<xref:System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs>|<xref:System.Web.UI.WebControls.ObjectDataSourceMethodEventHandler>|
|<xref:System.Web.UI.WebControls.ObjectDataSource.Selected><br /><br /> Occurs after the data is retrieved.|<xref:System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs>|<xref:System.Web.UI.WebControls.ObjectDataSourceStatusEventHandler>|
|<xref:System.Web.UI.WebControls.ObjectDataSource.Inserted>, <xref:System.Web.UI.WebControls.ObjectDataSource.Updated>, and <xref:System.Web.UI.WebControls.ObjectDataSource.Deleted>.<br /><br /> Occur after the insert, update, or delete operation is completed.|<xref:System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs>|<xref:System.Web.UI.WebControls.ObjectDataSourceStatusEventHandler>|
|<xref:System.Web.UI.WebControls.ObjectDataSource.ObjectDisposing>.<br /><br /> Occurs before a business object is destroyed.|<xref:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs>|<xref:System.Web.UI.WebControls.ObjectDataSourceDisposingEventHandler>|
## Examples
This section contains two code examples. The first code example demonstrates how to use an <xref:System.Web.UI.WebControls.ObjectDataSource> control with a business object and a <xref:System.Web.UI.WebControls.GridView> control to display information. The second code example provides the example middle-tier business object that the first code example uses.
The following code example demonstrates how to use an <xref:System.Web.UI.WebControls.ObjectDataSource> control with a business object and a <xref:System.Web.UI.WebControls.GridView> control to display information. You might work with a business object that is very expensive (in terms of time or resources) to create for every data operation that your Web page performs. One way to work with an expensive object might be to create an instance of it once, and then cache it for subsequent operations instead of creating and destroying it for every data operation. This example demonstrates this pattern. You can handle the <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectCreating> event to check the cache for an object first, and then create an instance, only if one is not already cached. Then, handle the <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectDisposing> event to cache the business object for future use, instead of destroying it. In this example, the <xref:System.ComponentModel.CancelEventArgs.Cancel?displayProperty=nameWithType> property of the <xref:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs> object is set to `true`, to direct the <xref:System.Web.UI.WebControls.ObjectDataSource> to not call the <xref:System.IDisposable.Dispose%2A> method on the instance.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_16/CS/objds16cs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_16/VB/objds16vb.aspx" id="Snippet1":::
The following code example provides an example middle-tier business object that the preceding code example uses. The code example consists of a basic business object, defined by the `EmployeeLogic` class, which is a class that maintains state and encapsulates business logic. For a complete working example, you must compile this code as a library, and then use these classes from an ASP page.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_16/CS/northwindemployee16.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_16/VB/northwindemployee16.vb" id="Snippet2":::
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.ObjectDataSourceDisposingEventHandler" />
<altmember cref="E:System.Web.UI.WebControls.ObjectDataSource.ObjectCreating" />
<altmember cref="P:System.Web.UI.WebControls.ObjectDataSourceEventArgs.ObjectInstance" />
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ObjectDataSourceDisposingEventArgs (object objectInstance);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(object objectInstance) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs.#ctor(System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (objectInstance As Object)" />
<MemberSignature Language="F#" Value="new System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs : obj -> System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs" Usage="new System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs objectInstance" />
<MemberSignature Language="C++ CLI" Value="public:
 ObjectDataSourceDisposingEventArgs(System::Object ^ objectInstance);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters>
<Parameter Name="objectInstance" Type="System.Object" />
</Parameters>
<Docs>
<param name="objectInstance">The business object with which the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> interacts to perform data operations.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs" /> class using the specified object.</summary>
<remarks>To be added.</remarks>
<altmember cref="P:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs.ObjectInstance" />
<altmember cref="T:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs" />
</Docs>
</Member>
<Member MemberName="ObjectInstance">
<MemberSignature Language="C#" Value="public object ObjectInstance { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance object ObjectInstance" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs.ObjectInstance" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property ObjectInstance As Object" />
<MemberSignature Language="F#" Value="member this.ObjectInstance : obj" Usage="System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs.ObjectInstance" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Object ^ ObjectInstance { System::Object ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Object</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets an object that represents the business object with which the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> control performs data operations.</summary>
<value>The business object the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> uses to data operations; otherwise, <see langword="null" />, if <see langword="null" /> is passed to the <see cref="T:System.Web.UI.WebControls.ObjectDataSourceEventArgs" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If the data operation methods (<xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A>, <xref:System.Web.UI.WebControls.ObjectDataSource.UpdateMethod%2A>, <xref:System.Web.UI.WebControls.ObjectDataSource.DeleteMethod%2A>, and <xref:System.Web.UI.WebControls.ObjectDataSource.InsertMethod%2A>) are instance methods, an instance of the business object is created before the method is executed. You can prevent the business object from being created for each call by saving the object in the <xref:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs.ObjectInstance%2A> property in the <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectDisposing> event handler. In subsequent <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectCreating> events, you can retrieve the business object from the <xref:System.Web.UI.WebControls.ObjectDataSourceEventArgs.ObjectInstance%2A> property.
## Examples
The following code example demonstrates how to use an <xref:System.Web.UI.WebControls.ObjectDataSource> control with a business object and a <xref:System.Web.UI.WebControls.GridView> control to display information. You might work with a business object that is very expensive (in terms of time or resources) to create for every data operation that your Web page performs. One way to work with an expensive object might be to create an instance of it once, and then cache it for subsequent operations instead of creating and destroying it for every data operation. This example demonstrates this pattern. You can handle the <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectCreating> event to check the cache for an object first, and then create an instance, only if one is not already cached. Then, handle the <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectDisposing> event to cache the business object for future use, instead of destroying it. In this example, the <xref:System.ComponentModel.CancelEventArgs.Cancel?displayProperty=nameWithType> property of the <xref:System.Web.UI.WebControls.ObjectDataSourceDisposingEventArgs> class is set to `true`, to direct the <xref:System.Web.UI.WebControls.ObjectDataSource> to not call <xref:System.IDisposable.Dispose%2A> on the instance.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_16/CS/objds16cs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_16/VB/objds16vb.aspx" id="Snippet1":::
]]></format>
</remarks>
<altmember cref="E:System.Web.UI.WebControls.ObjectDataSource.ObjectCreating" />
<altmember cref="P:System.Web.UI.WebControls.ObjectDataSourceEventArgs.ObjectInstance" />
</Docs>
</Member>
</Members>
</Type>