/
ObjectDataSource.xml
3485 lines (2946 loc) · 359 KB
/
ObjectDataSource.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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<Type Name="ObjectDataSource" FullName="System.Web.UI.WebControls.ObjectDataSource">
<TypeSignature Language="C#" Value="public class ObjectDataSource : System.Web.UI.DataSourceControl" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit ObjectDataSource extends System.Web.UI.DataSourceControl" />
<TypeSignature Language="DocId" Value="T:System.Web.UI.WebControls.ObjectDataSource" />
<TypeSignature Language="VB.NET" Value="Public Class ObjectDataSource
Inherits DataSourceControl" />
<TypeSignature Language="F#" Value="type ObjectDataSource = class
 inherit DataSourceControl" />
<TypeSignature Language="C++ CLI" Value="public ref class ObjectDataSource : System::Web::UI::DataSourceControl" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Web.UI.DataSourceControl</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.DefaultEvent("Selecting")]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DefaultEvent("Selecting")>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.DefaultProperty("TypeName")]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DefaultProperty("TypeName")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5">
<AttributeName Language="C#">[System.ComponentModel.Designer("System.Web.UI.Design.WebControls.ObjectDataSourceDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.Designer("System.Web.UI.Design.WebControls.ObjectDataSourceDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.ObjectDataSource))]</AttributeName>
<AttributeName Language="F#">[<System.Drawing.ToolboxBitmap(typeof(System.Web.UI.WebControls.ObjectDataSource))>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Web.UI.ParseChildren(true)]</AttributeName>
<AttributeName Language="F#">[<System.Web.UI.ParseChildren(true)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.Web.UI.PersistChildren(false)]</AttributeName>
<AttributeName Language="F#">[<System.Web.UI.PersistChildren(false)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.ComponentModel.Designer("System.Web.UI.Design.WebControls.ObjectDataSourceDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.Designer("System.Web.UI.Design.WebControls.ObjectDataSourceDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Represents a business object that provides data to data-bound controls in multitier Web application architectures.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
In this topic:
- [Introduction](#introduction)
- [Purpose](#purpose)
- [Retrieving Data](#retrieving_data)
- [Performing Data Operations](#performing_data_operations)
- [Filtering Data](#filtering_data)
- [Caching](#caching)
- [Features](#features)
- [Data View](#data_view)
- [Using LINQ to SQL](#using_linq_to_sql)
- [Declarative Syntax](#declarative_syntax)
<a name="introduction"></a>
## Introduction
An <xref:System.Web.UI.WebControls.ObjectDataSource> control works with a class that you create. You create methods that retrieve and update data, and you provide the names of those methods to the <xref:System.Web.UI.WebControls.ObjectDataSource> control in markup. During rendering or postback processing, the <xref:System.Web.UI.WebControls.ObjectDataSource> calls the methods that you have specified.
There is no visual rendering of the <xref:System.Web.UI.WebControls.ObjectDataSource> control. As a result, the <xref:System.Web.UI.WebControls.ObjectDataSource> does not support visual features such as the <xref:System.Web.UI.DataSourceControl.EnableTheming%2A> or <xref:System.Web.UI.DataSourceControl.SkinID%2A> property.
<a name="purpose"></a>
## 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. The <xref:System.Web.UI.WebControls.ObjectDataSource> control enables developers to use an ASP.NET data source control while retaining their three-tier application architecture.
The <xref:System.Web.UI.WebControls.ObjectDataSource> control uses reflection to create instances of business objects and to call methods on them to retrieve, update, insert, and delete data. The <xref:System.Web.UI.WebControls.ObjectDataSource.TypeName%2A> property identifies the name of the class that the <xref:System.Web.UI.WebControls.ObjectDataSource> works with. The <xref:System.Web.UI.WebControls.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. Using an expensive object might not be an optimal design choice, but you can control the life cycle of the object by using the <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectCreating>, <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectCreated>, and <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectDisposing> events.
> [!NOTE]
> The methods that are identified by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A>, <xref:System.Web.UI.WebControls.ObjectDataSource.UpdateMethod%2A>, <xref:System.Web.UI.WebControls.ObjectDataSource.InsertMethod%2A>, and <xref:System.Web.UI.WebControls.ObjectDataSource.DeleteMethod%2A> properties can be instance methods or `static` (`Shared` in Visual Basic) methods. If the methods are `static` (`Shared` in Visual Basic), an instance of the business object is not created, and the <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectCreating>, <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectCreated>, and <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectDisposing> events are not raised.
<a name="retrieving_data"></a>
## Retrieving Data
To retrieve data from a business object, set the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property to the name of the method that retrieves data. If the method does not return an <xref:System.Collections.IEnumerable> or <xref:System.Data.DataSet> object, the object is wrapped by the runtime in an <xref:System.Collections.IEnumerable> collection. If the method signature has parameters, you can add <xref:System.Web.UI.WebControls.Parameter> objects to the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectParameters%2A> collection, and then bind them to the values that you want to pass to the method that is specified by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property. In order for the <xref:System.Web.UI.WebControls.ObjectDataSource> control to use the parameters, the parameters must match the names and types of the parameters in the method signature. For more information, see [Using Parameters with the ObjectDataSource Control](https://msdn.microsoft.com/library/45fb67ee-9be7-49b7-9421-e242203dafa4).
The <xref:System.Web.UI.WebControls.ObjectDataSource> control retrieves data whenever the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method is called. This method provides programmatic access to the method that is specified by <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property. The method that is specified by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property is called automatically by controls that are bound to the <xref:System.Web.UI.WebControls.ObjectDataSource> when their `DataBind` method is called. If you set the `DataSourceID` property of a data-bound control, the control automatically binds to data from the data source, as needed. Setting the `DataSourceID` property is the recommended method for binding an <xref:System.Web.UI.WebControls.ObjectDataSource> control to a data-bound control. Alternatively, you can set the `DataSource` property, but then you must explicitly call the `DataBind` method of the data-bound control. You can call the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> 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](https://msdn.microsoft.com/library/e41adfff-8fb8-449e-9cd1-9bd49788c5f7).
<a name="performing_data_operations"></a>
## Performing Data Operations
Depending on the capabilities of the business object that the <xref:System.Web.UI.WebControls.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. For example, for an update operation, set the <xref:System.Web.UI.WebControls.ObjectDataSource.UpdateMethod%2A> property to the name of the business object method that performs updates and add any required parameters to the <xref:System.Web.UI.WebControls.ObjectDataSource.UpdateParameters%2A> collection. If the <xref:System.Web.UI.WebControls.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. The update is performed when the <xref:System.Web.UI.WebControls.ObjectDataSource.Update%2A> method is called, either explicitly by your code or automatically by a data-bound control. The same general pattern is followed for <xref:System.Web.UI.WebControls.ObjectDataSource.Delete%2A> and <xref:System.Web.UI.WebControls.ObjectDataSource.Insert%2A> operations. Business objects are assumed to perform these types of data operations one record at a time, rather than batched.
<a name="filtering_data"></a>
## Filtering Data
The <xref:System.Web.UI.WebControls.ObjectDataSource> control can filter data that is retrieved by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property, if the data is returned as a <xref:System.Data.DataSet> or <xref:System.Data.DataTable> object. You can set the <xref:System.Web.UI.WebControls.ObjectDataSource.FilterExpression%2A> property to a filtering expression by using a format string syntax and bind values in the expression to parameters that are specified in the <xref:System.Web.UI.WebControls.ObjectDataSource.FilterParameters%2A> collection.
<a name="caching"></a>
## Caching
Although the <xref:System.Web.UI.WebControls.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 <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property. While the data is cached, subsequent calls to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method return the cached data instead of creating the business object and calling its <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> using reflection. Caching lets you avoid creating the object and calling its data method at the expense of memory on the Web server. The <xref:System.Web.UI.WebControls.ObjectDataSource> automatically caches data when the <xref:System.Web.UI.WebControls.ObjectDataSource.EnableCaching%2A> property is set to `true`, and the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A> property is set to the number of seconds that the cache stores data before the cache is discarded. You can also specify a <xref:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy%2A> property and an optional <xref:System.Web.UI.WebControls.ObjectDataSource.SqlCacheDependency%2A> property. The <xref:System.Web.UI.WebControls.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 <xref:System.Data.SqlClient.SqlDataReader> object), because the same instance of the object will be used to service multiple requests.
<a name="features"></a>
## Features
The following table describes the features of the <xref:System.Web.UI.WebControls.ObjectDataSource> control.
|Capability|Requirements|
|----------------|------------------|
|Selecting|Set the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property to the name of the business object method that selects data, and include any necessary parameters in the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectParameters%2A> collection either programmatically or by using a data-bound control.|
|Sorting|Set the <xref:System.Web.UI.WebControls.ObjectDataSource.SortParameterName%2A> property to the name of the parameter in the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> method that carries the sort criteria.|
|Filtering|Set the <xref:System.Web.UI.WebControls.ObjectDataSource.FilterExpression%2A> property to a filtering expression and optionally add any parameters to the <xref:System.Web.UI.WebControls.ObjectDataSource.FilterParameters%2A> collection to filter the data when the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method is called. The method specified by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property must return a <xref:System.Data.DataSet> or <xref:System.Data.DataTable>.|
|Paging|Data source paging is supported, if the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> method contains parameters for the maximum number of records to retrieve and the index of the first record to retrieve. The names of those parameters must be set in the <xref:System.Web.UI.WebControls.ObjectDataSource.MaximumRowsParameterName%2A> and <xref:System.Web.UI.WebControls.ObjectDataSource.StartRowIndexParameterName%2A> properties, respectively. A data-bound control might be able to perform paging itself, even if the <xref:System.Web.UI.WebControls.ObjectDataSource> control does not support paging directly in the method specified by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property. The requirement for the data-bound control to be able to do this is that the method specified by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property return an object that implements the <xref:System.Collections.ICollection> interface.|
|Updating|Set the <xref:System.Web.UI.WebControls.ObjectDataSource.UpdateMethod%2A> property to the name of the business object method that updates data, and include any necessary parameters in the <xref:System.Web.UI.WebControls.ObjectDataSource.UpdateParameters%2A> collection.|
|Deleting|Set the <xref:System.Web.UI.WebControls.ObjectDataSource.DeleteMethod%2A> property to the name of the business object method or function that deletes data, and include any necessary parameters in the <xref:System.Web.UI.WebControls.ObjectDataSource.DeleteParameters%2A> collection.|
|Inserting|Set the <xref:System.Web.UI.WebControls.ObjectDataSource.InsertMethod%2A> property to the name of the business object method or function that inserts data, and include any necessary parameters in the <xref:System.Web.UI.WebControls.ObjectDataSource.InsertParameters%2A> collection.|
|Caching|Set the <xref:System.Web.UI.WebControls.ObjectDataSource.EnableCaching%2A> property to `true`, and the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A> and <xref:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy%2A> properties according to the caching behavior you want for your cached data.|
> [!NOTE]
> When you use the <xref:System.Web.UI.WebControls.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. 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. In that case, October 5, 2009 would be entered in a <xref:System.Web.UI.WebControls.TextBox> control as 5/10/2009 but would be interpreted as May 10, 2009. October 15, 2009 would be entered as 15/10/2009, and would be rejected as an invalid date.
<a name="data_view"></a>
## Data View
As with all data source controls, the <xref:System.Web.UI.WebControls.ObjectDataSource> control is associated with a data source view class. While the <xref:System.Web.UI.WebControls.ObjectDataSource> control is the interface that the page developer uses to work with data, the <xref:System.Web.UI.WebControls.ObjectDataSourceView> class is the interface that data-bound controls work with. Additionally, the <xref:System.Web.UI.WebControls.ObjectDataSourceView> class describes the capabilities of the data source control, and performs the actual work. The <xref:System.Web.UI.WebControls.ObjectDataSource> control has only one associated <xref:System.Web.UI.WebControls.ObjectDataSourceView>, and it is always named `DefaultView`. While the <xref:System.Web.UI.WebControls.ObjectDataSourceView> object is exposed by the <xref:System.Web.UI.WebControls.ObjectDataSource.GetView%2A> method, many of its properties and methods are wrapped and exposed directly by the <xref:System.Web.UI.WebControls.ObjectDataSource> control. Behind the scenes, the <xref:System.Web.UI.WebControls.ObjectDataSourceView> object performs all data operations, including retrieving, inserting, updating, deleting, filtering, and sorting the data. For more information, see <xref:System.Web.UI.WebControls.ObjectDataSourceView>.
<a name="using_linq_to_sql"></a>
## Using LINQ to SQL
You can use the <xref:System.Web.UI.WebControls.ObjectDataSource> control with a LINQ to SQL class. To do so, you set the <xref:System.Web.UI.WebControls.ObjectDataSource.TypeName%2A> property to the name of the data-context class. You also set the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A>, <xref:System.Web.UI.WebControls.ObjectDataSource.UpdateMethod%2A>, <xref:System.Web.UI.WebControls.ObjectDataSource.InsertMethod%2A>, and <xref:System.Web.UI.WebControls.ObjectDataSource.DeleteMethod%2A> methods to the methods in the data-context class that perform the corresponding operations. You must create an event handler for the <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectDisposing> event in order to cancel disposing of the data-context class. This step is necessary because LINQ to SQL supports deferred execution, whereas the <xref:System.Web.UI.WebControls.ObjectDataSource> control tries to dispose the data context after the Select operation. For more information about how to create LINQ to SQL classes, see [How to: Create LINQ to SQL Classes in a Web Project](https://msdn.microsoft.com/library/20bf925f-2a6d-410d-8f65-7b5b8f555081). For an example of how to cancel the disposing of a data context class, see the <xref:System.Web.UI.WebControls.ObjectDataSource.ObjectDisposing> event.
## Using the Entity Framework
You can also use the <xref:System.Web.UI.WebControls.ObjectDataSource> control with the Entity Framework. For more information, see [Using the Entity Framework and the ObjectDataSource Control](https://go.microsoft.com/fwlink/?LinkId=209117).
<a name="declarative_syntax"></a>
## 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>
```
## Examples
This section shows an <xref:System.Web.UI.WebControls.ObjectDataSource> in markup in an .aspx page and it shows the business objects that it works with. The example is the .aspx page. It contains a <xref:System.Web.UI.WebControls.GridView> control that is bound to an <xref:System.Web.UI.WebControls.ObjectDataSource> control. The <xref:System.Web.UI.WebControls.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.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_1/CS/objds1cs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_1/VB/objds1vb.aspx" id="Snippet1":::
The following example shows the business object that the <xref:System.Web.UI.WebControls.ObjectDataSource> control in the .aspx page uses. (Many other <xref:System.Web.UI.WebControls.ObjectDataSource> code examples use this business object also.) The example consists of the following two basic classes:
- The `EmployeeLogic` class is the business logic class that the <xref:System.Web.UI.WebControls.ObjectDataSource> uses.
- The `NorthwindEmployee` class defines the data object that is returned by the `GetAllEmployees` method of the `EmployeeLogic` class.
An additional `NorthwindDataException` class is provided as a convenience.
This set of example classes works with the Northwind Traders database, which is available with Microsoft SQL Server and Microsoft Access. For a complete working example, you must compile and use these classes with the .aspx page example that is provided.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_1/CS/northwindemployee1.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_1/VB/northwindemployee1.vb" id="Snippet2":::
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.IDataSource" />
<altmember cref="T:System.Web.UI.DataSourceControl" />
<altmember cref="T:System.Web.UI.WebControls.ObjectDataSourceView" />
<related type="Article" href="https://msdn.microsoft.com/library/a806fa2c-fe6a-405f-869c-74e804a642ea">Walkthrough: Data Binding to a Custom Business Object</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms247258(v=vs.100)">Data Source Web Server Controls</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/9a4kyhcx(v=vs.100)">ObjectDataSource Control Overview</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms227436(v=vs.100)">Creating an ObjectDataSource Control Source Object</related>
<related type="ExternalDocumentation" href="https://go.microsoft.com/fwlink/?LinkId=214011">Using the Entity Framework and the ObjectDataSource Control</related>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> class.</summary>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms247258(v=vs.100)">Data Source Web Server Controls</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/9a4kyhcx(v=vs.100)">ObjectDataSource Control Overview</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms227436(v=vs.100)">Creating an ObjectDataSource Control Source Object</related>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ObjectDataSource ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.ObjectDataSource.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 ObjectDataSource();" />
<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 />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> class.</summary>
<remarks>To be added.</remarks>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms247258(v=vs.100)">Data Source Web Server Controls</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/9a4kyhcx(v=vs.100)">ObjectDataSource Control Overview</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms227436(v=vs.100)">Creating an ObjectDataSource Control Source Object</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ObjectDataSource (string typeName, string selectMethod);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string typeName, string selectMethod) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.ObjectDataSource.#ctor(System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (typeName As String, selectMethod As String)" />
<MemberSignature Language="F#" Value="new System.Web.UI.WebControls.ObjectDataSource : string * string -> System.Web.UI.WebControls.ObjectDataSource" Usage="new System.Web.UI.WebControls.ObjectDataSource (typeName, selectMethod)" />
<MemberSignature Language="C++ CLI" Value="public:
 ObjectDataSource(System::String ^ typeName, System::String ^ selectMethod);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="typeName" Type="System.String" />
<Parameter Name="selectMethod" Type="System.String" />
</Parameters>
<Docs>
<param name="typeName">The name of the class that the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> works with.</param>
<param name="selectMethod">The name of the method or function that the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> invokes to retrieve data.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> class with the specified type name and data retrieval method name.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The value of the `typeName` parameter can be a partially qualified type for code that is located in the Bin or App_Code directory or a fully qualified type name for code that is registered in the global assembly cache. If you use the global assembly cache, you must add the appropriate reference to the `assemblies` section of the Machine.config or Web.config configuration file.
]]></format>
</remarks>
<altmember cref="P:System.Web.UI.WebControls.ObjectDataSource.TypeName" />
<altmember cref="P:System.Web.UI.WebControls.ObjectDataSource.SelectMethod" />
<altmember cref="P:System.Web.UI.WebControls.ObjectDataSource.SelectParameters" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms247258(v=vs.100)">Data Source Web Server Controls</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/9a4kyhcx(v=vs.100)">ObjectDataSource Control Overview</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms227436(v=vs.100)">Creating an ObjectDataSource Control Source Object</related>
</Docs>
</Member>
<Member MemberName="CacheDuration">
<MemberSignature Language="C#" Value="public virtual int CacheDuration { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 CacheDuration" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.ObjectDataSource.CacheDuration" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property CacheDuration As Integer" />
<MemberSignature Language="F#" Value="member this.CacheDuration : int with get, set" Usage="System.Web.UI.WebControls.ObjectDataSource.CacheDuration" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual property int CacheDuration { int get(); void set(int value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.DefaultValue(0)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DefaultValue(0)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.TypeConverter(typeof(System.Web.UI.DataSourceCacheDurationConverter))]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.TypeConverter(typeof(System.Web.UI.DataSourceCacheDurationConverter))>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the length of time, in seconds, that the data source control caches data that is retrieved by the <see cref="P:System.Web.UI.WebControls.ObjectDataSource.SelectMethod" /> property.</summary>
<value>The number of seconds that the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> caches the results of a <see cref="P:System.Web.UI.WebControls.ObjectDataSource.SelectMethod" /> property invocation. The default is 0. The value cannot be negative.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.ObjectDataSource> control supports data caching. While data is cached, calls to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method retrieve data from the cache rather than from the business object that the <xref:System.Web.UI.WebControls.ObjectDataSource> works with. When the cache expires, the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method retrieves data from the business object, and then caches the data again.
The <xref:System.Web.UI.WebControls.ObjectDataSource> control automatically caches data when the <xref:System.Web.UI.WebControls.ObjectDataSource.EnableCaching%2A> property is set to `true` and the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A> property is set to a value greater than 0, which indicates the number of seconds that the cache stores data before the cache entry is discarded. A value of 0 indicates an infinitely long cache.
The cache is regulated by a combination of the duration and the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy%2A> setting. If the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy%2A> property is set to the <xref:System.Web.UI.DataSourceCacheExpiry.Absolute> value, the <xref:System.Web.UI.WebControls.ObjectDataSource> caches data on the first call to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method and holds it in memory for, at most, the amount of time that is specified by the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A> property. The data might be released before the duration time, if the memory is needed. The cache is then refreshed during the next call to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method. If the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy%2A> property is set to <xref:System.Web.UI.DataSourceCacheExpiry.Sliding> value, the data source control caches data on the first call to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method, but resets the time window for which it holds the cache on each subsequent call to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method. The cache expires if there is no activity for a time that is equal to the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A> property since the last call to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method.
## Examples
This section contains two code examples. The first code example demonstrates how an <xref:System.Web.UI.WebControls.ObjectDataSource> object supports caching. The second code example demonstrates how to implement a wrapper method that returns a <xref:System.Data.DataSet> object to enable caching with an <xref:System.Web.UI.WebControls.ObjectDataSource> object.
The following code example demonstrates how an <xref:System.Web.UI.WebControls.ObjectDataSource> control supports caching. To enable caching, you must implement the method that retrieves data, which is identified by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property, to return the data as a <xref:System.Data.DataSet> object. In this example, the <xref:System.Web.UI.WebControls.ObjectDataSource.EnableCaching%2A> property is set to `true`, and the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A> and <xref:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy%2A> properties are set. The <xref:System.Web.UI.WebControls.ObjectDataSource> caches data that is returned by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property for 30 seconds.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_6/CS/objds6cs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_6/VB/objds6vb.aspx" id="Snippet1":::
The following code example demonstrates how to implement a wrapper method that returns a <xref:System.Data.DataSet> object to enable caching with an <xref:System.Web.UI.WebControls.ObjectDataSource> control. In the base implementation of the `EmployeeLogic` class, the `GetAllEmployees` method returns an <xref:System.Collections.ArrayList> object. Instead of refactoring the object completely to work with the <xref:System.Web.UI.WebControls.ObjectDataSource> on a Web Forms page, a wrapper method named `GetAllEmployeesAsDataSet` is added that returns a set of `NorthwindEmployee` data as a <xref:System.Data.DataSet>.
This code example is part of a larger example provided for the <xref:System.Web.UI.WebControls.ObjectDataSource> class.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_5/CS/northwindemployee5.cs" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_5/VB/northwindemployee5.vb" id="Snippet3":::
]]></format>
</remarks>
<altmember cref="P:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy" />
<altmember cref="P:System.Web.UI.WebControls.ObjectDataSource.EnableCaching" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms247258(v=vs.100)">Data Source Web Server Controls</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/9a4kyhcx(v=vs.100)">ObjectDataSource Control Overview</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms227436(v=vs.100)">Creating an ObjectDataSource Control Source Object</related>
</Docs>
</Member>
<Member MemberName="CacheExpirationPolicy">
<MemberSignature Language="C#" Value="public virtual System.Web.UI.DataSourceCacheExpiry CacheExpirationPolicy { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Web.UI.DataSourceCacheExpiry CacheExpirationPolicy" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property CacheExpirationPolicy As DataSourceCacheExpiry" />
<MemberSignature Language="F#" Value="member this.CacheExpirationPolicy : System.Web.UI.DataSourceCacheExpiry with get, set" Usage="System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual property System::Web::UI::DataSourceCacheExpiry CacheExpirationPolicy { System::Web::UI::DataSourceCacheExpiry get(); void set(System::Web::UI::DataSourceCacheExpiry value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.DefaultValue(System.Web.UI.DataSourceCacheExpiry.Absolute)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DefaultValue(System.Web.UI.DataSourceCacheExpiry.Absolute)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.DataSourceCacheExpiry</ReturnType>
</ReturnValue>
<Docs>
<summary>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.</summary>
<value>One of the <see cref="T:System.Web.UI.DataSourceCacheExpiry" /> values. The default is <see cref="F:System.Web.UI.DataSourceCacheExpiry.Absolute" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.ObjectDataSource> control supports data caching. While data is cached, calls to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method retrieve data from the cache rather than from the business object that the <xref:System.Web.UI.WebControls.ObjectDataSource> works with. When the cache expires, the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method retrieves data from the business object, and then caches the data again.
The <xref:System.Web.UI.WebControls.ObjectDataSource> control automatically caches data when the <xref:System.Web.UI.WebControls.ObjectDataSource.EnableCaching%2A> property is set to `true` and the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A> property is set to a value greater than 0, which indicates the number of seconds that the cache stores data before the cache entry is discarded. A value of 0 indicates an infinitely long cache period.
The cache is regulated by a combination of the duration and the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy%2A> setting. If the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy%2A> property is set to the <xref:System.Web.UI.DataSourceCacheExpiry.Absolute> value, the <xref:System.Web.UI.WebControls.ObjectDataSource> caches data on the first call to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method and holds it in memory for, at most, the amount of time that is specified by the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A> property. The data might be released before the duration time, if the memory is needed. The cache is then refreshed during the next call to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method. If the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy%2A> property is set to the <xref:System.Web.UI.DataSourceCacheExpiry.Sliding> value, the data source control caches data on the first call to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method, but resets the time window for which it holds the cache for each subsequent call to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method. The cache expires if there is no activity for a time that is equal to the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A> property since the last call to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method.
## Examples
This section contains two code examples. The first code example demonstrates how an <xref:System.Web.UI.WebControls.ObjectDataSource> object supports filtering and caching. The second code example demonstrates how to implement a wrapper method that returns a <xref:System.Data.DataSet> object to enable caching and filtering with an <xref:System.Web.UI.WebControls.ObjectDataSource> object.
The following code example demonstrates how an <xref:System.Web.UI.WebControls.ObjectDataSource> control supports filtering and caching. To enable filtering and caching, you must implement the method that retrieves data, which is identified by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property, to return the data as a <xref:System.Data.DataSet> object. In this example, caching is enabled because the `EmployeeLogic` object returns data as a <xref:System.Data.DataSet>, the <xref:System.Web.UI.WebControls.ObjectDataSource.EnableCaching%2A> property is set to `true`, and the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A> and <xref:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy%2A> properties are set. The <xref:System.Web.UI.WebControls.ObjectDataSource> caches data that is returned by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property for 30 seconds.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_6/CS/objds6cs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_6/VB/objds6vb.aspx" id="Snippet1":::
The following code example demonstrates how to implement a wrapper method that returns a <xref:System.Data.DataSet> object to enable caching and filtering with an <xref:System.Web.UI.WebControls.ObjectDataSource> control. In the base implementation of the `EmployeeLogic` class, the `GetAllEmployees` method returns an <xref:System.Collections.ArrayList>. Instead of refactoring the object completely to work with the <xref:System.Web.UI.WebControls.ObjectDataSource> on a Web Forms page, a wrapper method named `GetAllEmployeesAsDataSet` is added that returns a set of `NorthwindEmployee` data as a <xref:System.Data.DataSet>. This code example is part of a larger example provided for the <xref:System.Web.UI.WebControls.ObjectDataSource> class.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_5/CS/northwindemployee5.cs" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_5/VB/northwindemployee5.vb" id="Snippet3":::
]]></format>
</remarks>
<altmember cref="P:System.Web.UI.WebControls.ObjectDataSource.CacheDuration" />
<altmember cref="P:System.Web.UI.WebControls.ObjectDataSource.EnableCaching" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms247258(v=vs.100)">Data Source Web Server Controls</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/9a4kyhcx(v=vs.100)">ObjectDataSource Control Overview</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms227436(v=vs.100)">Creating an ObjectDataSource Control Source Object</related>
</Docs>
</Member>
<Member MemberName="CacheKeyDependency">
<MemberSignature Language="C#" Value="public virtual string CacheKeyDependency { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string CacheKeyDependency" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.ObjectDataSource.CacheKeyDependency" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property CacheKeyDependency As String" />
<MemberSignature Language="F#" Value="member this.CacheKeyDependency : string with get, set" Usage="System.Web.UI.WebControls.ObjectDataSource.CacheKeyDependency" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual property System::String ^ CacheKeyDependency { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.DefaultValue("")]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DefaultValue("")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a user-defined key dependency that is linked to all data cache objects that are created by the data source control.</summary>
<value>A key that identifies all cache objects created by the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.ObjectDataSource.CacheKeyDependency%2A> property can be set to any arbitrary string value.
All cache objects are explicitly expired when the key is expired. This allows you to invalidate cache entries that are created by the <xref:System.Web.UI.WebControls.ObjectDataSource> from your own page code programmatically.
The <xref:System.Web.UI.WebControls.ObjectDataSource> control supports data caching. While data is cached, calls to the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method retrieve data from the cache rather than from the business object that the <xref:System.Web.UI.WebControls.ObjectDataSource> works with. When the cache expires, the <xref:System.Web.UI.WebControls.ObjectDataSource.Select%2A> method retrieves data from the business object, and then caches the data again.
The <xref:System.Web.UI.WebControls.ObjectDataSource> control automatically caches data when the <xref:System.Web.UI.WebControls.ObjectDataSource.EnableCaching%2A> property is set to `true` and the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A> property is set to a value greater than 0, which indicates the number of seconds that the cache stores data before the cache entry is discarded. A value of 0 indicates an infinitely long cache.
You can set the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheKeyDependency%2A> property to create a dependency between all cache entries that are created by the <xref:System.Web.UI.WebControls.ObjectDataSource> control and the key. You can expire all the cache entries programmatically at any time by expiring the key. Expire the key by using the <xref:System.Web.Caching.Cache.Remove%2A?displayProperty=nameWithType> method with the current <xref:System.Web.UI.WebControls.ObjectDataSource.CacheKeyDependency%2A> value as the parameter.
A unique cache entry is created for every combination of the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheDuration%2A>, <xref:System.Web.UI.WebControls.ObjectDataSource.CacheExpirationPolicy%2A>, <xref:System.Web.UI.WebControls.ObjectDataSource.TypeName%2A>, <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A>, and <xref:System.Web.UI.WebControls.ObjectDataSource.SelectParameters%2A> properties. Multiple <xref:System.Web.UI.WebControls.ObjectDataSource> controls can use the same cache entries in scenarios where they load data using the same type, method, and parameters.
## Examples
The following three examples show a Web page, a code-behind page class, and a data-access class that retrieve records from the Employees table in the Northwind database.
The first example shows a Web page that contains two <xref:System.Web.UI.WebControls.ObjectDataSource> controls, a <xref:System.Web.UI.WebControls.DropDownList> control, and a <xref:System.Web.UI.WebControls.DetailsView> control. The first <xref:System.Web.UI.WebControls.ObjectDataSource> control and the <xref:System.Web.UI.WebControls.DropDownList> control are used to retrieve and display employee names from the database. The second <xref:System.Web.UI.WebControls.ObjectDataSource> control and the <xref:System.Web.UI.WebControls.DetailsView> control are used to retrieve and display the employee record that is selected by the user.
Caching is enabled for the <xref:System.Web.UI.WebControls.ObjectDataSource> control. Therefore, each record is retrieved only one time from the database. The <xref:System.Web.UI.WebControls.ObjectDataSource.CacheKeyDependency%2A> property is set to "EmployeeDetails", but any string value can work as the key. The Web page also includes a <xref:System.Web.UI.WebControls.Button> control that the user can click to expire the cached data.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_18/CS/Default2.aspx" id="Snippet3":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_18/VB/Default2.aspx" id="Snippet3":::
The second example shows a handler for the <xref:System.Web.UI.Control.Load> event and a handler for the <xref:System.Web.UI.WebControls.Button.Click> event of the <xref:System.Web.UI.WebControls.Button> control. The <xref:System.Web.UI.Control.Load> event handler creates a cache item with a key set to the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheKeyDependency%2A> value. The <xref:System.Web.UI.WebControls.Button.Click> event handler removes the cache item whose key is equal to the <xref:System.Web.UI.WebControls.ObjectDataSource.CacheKeyDependency%2A> value. When the cache item is removed, all the cached data that is dependent on the key is expired.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_18/CS/Default2.aspx.cs" id="Snippet4":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_18/VB/Default2.aspx.vb" id="Snippet4":::
The third example shows the data access class that interacts with the Northwind database. The class uses LINQ to query the Employees table. The example requires a LINQ to SQL class that represents the Northwind database and the Employees table. For more information, see [How to: Create LINQ to SQL Classes in a Web Project](https://msdn.microsoft.com/library/20bf925f-2a6d-410d-8f65-7b5b8f555081).
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_18/CS/App_Code/EmployeeLogic.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/System.Web.UI.WebControls.ObjectDataSource_18/VB/App_Code/EmployeeLogic.vb" id="Snippet5":::
]]></format>
</remarks>
<altmember cref="T:System.Web.Caching.SqlCacheDependency" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms247258(v=vs.100)">Data Source Web Server Controls</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/9a4kyhcx(v=vs.100)">ObjectDataSource Control Overview</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms227436(v=vs.100)">Creating an ObjectDataSource Control Source Object</related>
</Docs>
</Member>
<Member MemberName="ConflictDetection">
<MemberSignature Language="C#" Value="public System.Web.UI.ConflictOptions ConflictDetection { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Web.UI.ConflictOptions ConflictDetection" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.ObjectDataSource.ConflictDetection" />
<MemberSignature Language="VB.NET" Value="Public Property ConflictDetection As ConflictOptions" />
<MemberSignature Language="F#" Value="member this.ConflictDetection : System.Web.UI.ConflictOptions with get, set" Usage="System.Web.UI.WebControls.ObjectDataSource.ConflictDetection" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Web::UI::ConflictOptions ConflictDetection { System::Web::UI::ConflictOptions get(); void set(System::Web::UI::ConflictOptions value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.DefaultValue(System.Web.UI.ConflictOptions.OverwriteChanges)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DefaultValue(System.Web.UI.ConflictOptions.OverwriteChanges)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Web.UI.ConflictOptions</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value that determines whether or not just the new values are passed to the <see langword="Update" /> method or both the old and new values are passed to the <see langword="Update" /> method.</summary>
<value>One of the <see cref="T:System.Web.UI.ConflictOptions" /> values. The default is <see cref="F:System.Web.UI.ConflictOptions.OverwriteChanges" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This property determines whether parameters for old and new values are applied to the method specified by the <xref:System.Web.UI.WebControls.ObjectDataSource.UpdateMethod%2A> property. For example, if the method that is specified by the <xref:System.Web.UI.WebControls.ObjectDataSource.SelectMethod%2A> property returns a <xref:System.Data.DataTable> control with the columns `Name` and `Number`, and the <xref:System.Web.UI.WebControls.ObjectDataSource.ConflictDetection%2A> property is set to the <xref:System.Web.UI.ConflictOptions.OverwriteChanges> field, parameters are created for `Name` and `Number` for the `Update` method. If the <xref:System.Web.UI.WebControls.ObjectDataSource.ConflictDetection%2A> property is set to the <xref:System.Web.UI.ConflictOptions.CompareAllValues> value, parameters are created for `Name`, `Number`, `original_Name`, and `original_Number`. (The exact name of the parameters for the original values depends on the <xref:System.Web.UI.WebControls.ObjectDataSource.OldValuesParameterFormatString%2A> property.) The <xref:System.Web.UI.WebControls.ObjectDataSource> then determines whether the method that is specified in the <xref:System.Web.UI.WebControls.ObjectDataSource.UpdateMethod%2A> property has parameters that match.
Concurrency control is a technique that data stores use to control how data is read and changed in the store when multiple clients are accessing and manipulating the same data. For example, one client reads data and presents it to a user, while another client reads the same data and presents it to a different user. If both users update the data and submit it to the data storage, an unexpected result might occur, because both clients might provide different values for the same data. This is considered a conflict. By setting the <xref:System.Web.UI.WebControls.ObjectDataSource.ConflictDetection%2A> property to the <xref:System.Web.UI.ConflictOptions.CompareAllValues> value, the `Update` method can then compare the old and new values to the original data source to detect conflicts and handle them as necessary.
The <xref:System.Web.UI.WebControls.ObjectDataSource.ConflictDetection%2A> property delegates to the <xref:System.Web.UI.WebControls.ObjectDataSourceView.ConflictDetection%2A> property of the <xref:System.Web.UI.WebControls.ObjectDataSourceView> object that is associated with the <xref:System.Web.UI.WebControls.ObjectDataSource> control.
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.ConflictOptions" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms247258(v=vs.100)">Data Source Web Server Controls</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/9a4kyhcx(v=vs.100)">ObjectDataSource Control Overview</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms227436(v=vs.100)">Creating an ObjectDataSource Control Source Object</related>
</Docs>
</Member>
<Member MemberName="ConvertNullToDBNull">
<MemberSignature Language="C#" Value="public bool ConvertNullToDBNull { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool ConvertNullToDBNull" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.ObjectDataSource.ConvertNullToDBNull" />
<MemberSignature Language="VB.NET" Value="Public Property ConvertNullToDBNull As Boolean" />
<MemberSignature Language="F#" Value="member this.ConvertNullToDBNull : bool with get, set" Usage="System.Web.UI.WebControls.ObjectDataSource.ConvertNullToDBNull" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool ConvertNullToDBNull { bool get(); void set(bool value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.DefaultValue(false)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DefaultValue(false)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value indicating whether the <see cref="T:System.Web.UI.WebControls.Parameter" /> values that are passed to an update, insert, or delete operation are automatically converted from <see langword="null" /> to the <see cref="F:System.DBNull.Value" /> value by the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> control.</summary>
<value>
<see langword="true" />, if any <see langword="null" /> values in <see cref="T:System.Web.UI.WebControls.Parameter" /> objects passed to the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> control are automatically converted to <see cref="F:System.DBNull.Value" /> values; otherwise, <see langword="false" />. The default is <see langword="false" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Not converting `null` to the <xref:System.DBNull.Value> value can result in errors at run time. Use the <xref:System.Web.UI.WebControls.ObjectDataSource.ConvertNullToDBNull%2A> property to indicate whether <xref:System.Web.UI.WebControls.Parameter> values that are passed to an update, insert, or delete operation are automatically converted from `null` to the <xref:System.DBNull.Value> value by the <xref:System.Web.UI.WebControls.ObjectDataSource> control.
]]></format>
</remarks>
<altmember cref="F:System.DBNull.Value" />
<altmember cref="T:System.Web.UI.WebControls.ObjectDataSource" />
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms247258(v=vs.100)">Data Source Web Server Controls</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/9a4kyhcx(v=vs.100)">ObjectDataSource Control Overview</related>
<related type="Article" href="https://docs.microsoft.com/previous-versions/aspnet/ms227436(v=vs.100)">Creating an ObjectDataSource Control Source Object</related>
</Docs>
</Member>
<Member MemberName="DataObjectTypeName">
<MemberSignature Language="C#" Value="public string DataObjectTypeName { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance string DataObjectTypeName" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.ObjectDataSource.DataObjectTypeName" />
<MemberSignature Language="VB.NET" Value="Public Property DataObjectTypeName As String" />
<MemberSignature Language="F#" Value="member this.DataObjectTypeName : string with get, set" Usage="System.Web.UI.WebControls.ObjectDataSource.DataObjectTypeName" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ DataObjectTypeName { System::String ^ get(); void set(System::String ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.DefaultValue("")]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DefaultValue("")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the name of a class that the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> control uses for a parameter in an update, insert, or delete data operation, instead of passing individual values from the data-bound control.</summary>
<value>A partially or fully qualified class name that identifies the type of the object that the <see cref="T:System.Web.UI.WebControls.ObjectDataSource" /> can use as a parameter for an <see cref="M:System.Web.UI.WebControls.ObjectDataSource.Insert" />, <see cref="M:System.Web.UI.WebControls.ObjectDataSource.Update" />, or a <see cref="M:System.Web.UI.WebControls.ObjectDataSource.Delete" /> operation. The default is an empty string ("").</value>
<remarks>
<format type="text/markdown"><![CDATA[