-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
LinqDataSourceDeleteEventArgs.xml
228 lines (209 loc) · 17.8 KB
/
LinqDataSourceDeleteEventArgs.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<Type Name="LinqDataSourceDeleteEventArgs" FullName="System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs">
<TypeSignature Language="C#" Value="public class LinqDataSourceDeleteEventArgs : System.ComponentModel.CancelEventArgs" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit LinqDataSourceDeleteEventArgs extends System.ComponentModel.CancelEventArgs" />
<TypeSignature Language="DocId" Value="T:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs" />
<TypeSignature Language="VB.NET" Value="Public Class LinqDataSourceDeleteEventArgs
Inherits CancelEventArgs" />
<TypeSignature Language="F#" Value="type LinqDataSourceDeleteEventArgs = class
 inherit CancelEventArgs" />
<TypeSignature Language="C++ CLI" Value="public ref class LinqDataSourceDeleteEventArgs : System::ComponentModel::CancelEventArgs" />
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.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.LinqDataSource.Deleting" /> event.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs> object is passed to any handler for the <xref:System.Web.UI.WebControls.LinqDataSource.Deleting> event. The <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.OriginalObject%2A> property contains the data that will be deleted.
If the object that represents the data source throws a validation exception before it deletes the data, the <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.Exception%2A> property contains an instance of the <xref:System.Web.UI.WebControls.LinqDataSourceValidationException> class. You can retrieve all the validation exceptions through the <xref:System.Web.UI.WebControls.LinqDataSourceValidationException.InnerExceptions%2A> property. If no validation exception is thrown, the <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.Exception%2A> property contains `null`. If you handle the validation exceptions and do not want the exception to be re-thrown, set the <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.ExceptionHandled%2A> property to `true`.
You create an event handler for the <xref:System.Web.UI.WebControls.LinqDataSource.Deleting> event to validate the data, to examine validation errors from the data class, or to cancel the delete operation. You cancel the delete operation by setting the <xref:System.ComponentModel.CancelEventArgs.Cancel%2A> property to `true`.
By default, the <xref:System.Web.UI.WebControls.LinqDataSource> control stores the original values from the data source in view state in the Web page, except those whose <xref:System.Data.Linq.Mapping.ColumnAttribute> attribute is marked as `UpdateCheck.Never`. LINQ to SQL automatically checks the integrity of the data before deleting the data. It does this by comparing the current values in the data source with the original values that are stored in view state. You can perform additional data validation by creating a handler for the <xref:System.Web.UI.WebControls.LinqDataSource.Deleting> event.
## Examples
The following example shows how to cancel the delete operation based on a property in the <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.OriginalObject%2A> property and a value from the Web page. In the example, users must select a <xref:System.Web.UI.WebControls.CheckBox> control to confirm that they want to delete a product record when its `OnSale` property is set to `true`.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.LinqDataSource.Deleting/cs/Default.aspx.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.LinqDataSource.Deleting/vb/Default.aspx.vb" id="Snippet1":::
]]></format>
</remarks>
<related type="Article" href="/dotnet/framework/data/adonet/sql/linq/">LINQ to SQL</related>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public LinqDataSourceDeleteEventArgs (object originalObject);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(object originalObject) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.#ctor(System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (originalObject As Object)" />
<MemberSignature Language="F#" Value="new System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs : obj -> System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs" Usage="new System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs originalObject" />
<MemberSignature Language="C++ CLI" Value="public:
 LinqDataSourceDeleteEventArgs(System::Object ^ originalObject);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.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="originalObject" Type="System.Object" />
</Parameters>
<Docs>
<param name="originalObject">An object of the type specified in the <see cref="P:System.Web.UI.WebControls.LinqDataSource.TableName" /> property that contains the data to delete.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs" /> class.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public LinqDataSourceDeleteEventArgs (System.Web.UI.WebControls.LinqDataSourceValidationException exception);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Web.UI.WebControls.LinqDataSourceValidationException exception) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.#ctor(System.Web.UI.WebControls.LinqDataSourceValidationException)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (exception As LinqDataSourceValidationException)" />
<MemberSignature Language="F#" Value="new System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs : System.Web.UI.WebControls.LinqDataSourceValidationException -> System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs" Usage="new System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs exception" />
<MemberSignature Language="C++ CLI" Value="public:
 LinqDataSourceDeleteEventArgs(System::Web::UI::WebControls::LinqDataSourceValidationException ^ exception);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.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="exception" Type="System.Web.UI.WebControls.LinqDataSourceValidationException" />
</Parameters>
<Docs>
<param name="exception">The exception that occurred when validating the data to delete.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs" /> class with the specified exception.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Exception">
<MemberSignature Language="C#" Value="public System.Web.UI.WebControls.LinqDataSourceValidationException Exception { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.LinqDataSourceValidationException Exception" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.Exception" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Exception As LinqDataSourceValidationException" />
<MemberSignature Language="F#" Value="member this.Exception : System.Web.UI.WebControls.LinqDataSourceValidationException" Usage="System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.Exception" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Web::UI::WebControls::LinqDataSourceValidationException ^ Exception { System::Web::UI::WebControls::LinqDataSourceValidationException ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.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.Web.UI.WebControls.LinqDataSourceValidationException</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the exception that was thrown while the data was being validated before the delete operation.</summary>
<value>The exception, if an error occurred; otherwise, <see langword="null" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If a validation exception is thrown before the delete operation is performed, the exception is stored in the <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.Exception%2A> property. In an event handler for the <xref:System.Web.UI.WebControls.LinqDataSource.Deleting> event, you can retrieve the exception through the <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.Exception%2A> property.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="ExceptionHandled">
<MemberSignature Language="C#" Value="public bool ExceptionHandled { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool ExceptionHandled" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.ExceptionHandled" />
<MemberSignature Language="VB.NET" Value="Public Property ExceptionHandled As Boolean" />
<MemberSignature Language="F#" Value="member this.ExceptionHandled : bool with get, set" Usage="System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.ExceptionHandled" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool ExceptionHandled { bool get(); void set(bool value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.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>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value that indicates whether the exception was handled and that it should not be thrown again.</summary>
<value>
<see langword="true" /> if the exception was handled; otherwise, <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can create an event handler for the <xref:System.Web.UI.WebControls.LinqDataSource.Deleting> event to examine validation exceptions that were thrown before the delete operation. If you handle the exception and do not want it to be thrown again, set the <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.ExceptionHandled%2A> property to `true`. If you do not set the <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.ExceptionHandled%2A> property to `true`, the exception will be propagated to the next event handler in the call stack.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="OriginalObject">
<MemberSignature Language="C#" Value="public object OriginalObject { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance object OriginalObject" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.OriginalObject" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property OriginalObject As Object" />
<MemberSignature Language="F#" Value="member this.OriginalObject : obj" Usage="System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.OriginalObject" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Object ^ OriginalObject { System::Object ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web.Extensions</AssemblyName>
<AssemblyVersion>3.5.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 the object that represents the data to delete.</summary>
<value>An object of the type specified in the <see cref="P:System.Web.UI.WebControls.LinqDataSource.TableName" /> property that contains the data to delete.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can use the <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.OriginalObject%2A> property to interact with the data before it is deleted. You can validate the data, or you can cancel the event by setting the <xref:System.ComponentModel.CancelEventArgs.Cancel%2A> property to `true`. You can modify which record is deleted by changing the value or values of the object in the <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.OriginalObject%2A> property.
## Examples
The following example shows how to cancel the delete operation based on a property in the <xref:System.Web.UI.WebControls.LinqDataSourceDeleteEventArgs.OriginalObject%2A> property and a value from the Web page. In the example, users must select a <xref:System.Web.UI.WebControls.CheckBox> control to confirm that they want to delete a product record when its `OnSale` property is set to `true`.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.LinqDataSource.Deleting/cs/Default.aspx.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.LinqDataSource.Deleting/vb/Default.aspx.vb" id="Snippet1":::
]]></format>
</remarks>
</Docs>
</Member>
</Members>
</Type>