- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
Main Properties of ObjectDataSource in C#.NET
Main Properties of ObjectDataSource Quick Response Code Printer In Visual C#.NET Using Barcode creation for Visual Studio .NET Control to generate, create QR image in .NET applications. www.OnBarcode.comRecognize QR Code In Visual C# Using Barcode reader for .NET Control to read, scan read, scan image in .NET framework applications. www.OnBarcode.comDescription
Painting Barcode In C# Using Barcode encoder for VS .NET Control to generate, create bar code image in Visual Studio .NET applications. www.OnBarcode.comBar Code Scanner In C#.NET Using Barcode scanner for .NET framework Control to read, scan read, scan image in VS .NET applications. www.OnBarcode.comIndicates whether null parameters passed to insert, delete, or update operations are converted to System.DBNull. This property is set to false by default. Gets or sets the name of a class that is to be used as a parameter for a select, insert, update, or delete operation. Gets or sets the name of the method and related parameters used to perform a delete operation. Indicates whether the control supports paging. Indicates the filter expression (and parameters) to filter the output of a select operation. Gets or sets the name of the method and related parameters used to perform an insert operation. If the EnablePaging property is set to true, indicates the parameter name of the Select method that accepts the value for the number of records to retrieve. Gets or sets a format string to apply to the names of any parameters passed to the Delete or Update methods. Gets or sets the name of the method used to perform a select count operation. QR Code JIS X 0510 Encoder In VS .NET Using Barcode drawer for ASP.NET Control to generate, create QR Code image in ASP.NET applications. www.OnBarcode.comMaking QR Code 2d Barcode In .NET Framework Using Barcode generator for VS .NET Control to generate, create QR-Code image in .NET framework applications. www.OnBarcode.comProperty
Drawing QR-Code In Visual Basic .NET Using Barcode drawer for Visual Studio .NET Control to generate, create QR Code image in Visual Studio .NET applications. www.OnBarcode.comPrinting UCC - 12 In Visual C# Using Barcode generator for .NET Control to generate, create EAN128 image in VS .NET applications. www.OnBarcode.comConvertNullToDBNull
Making Code-128 In C# Using Barcode generator for .NET framework Control to generate, create Code 128 Code Set A image in .NET framework applications. www.OnBarcode.comQR Encoder In Visual C# Using Barcode encoder for Visual Studio .NET Control to generate, create Denso QR Bar Code image in .NET applications. www.OnBarcode.comDataObjectTypeName DeleteMethod, DeleteParameters EnablePaging FilterExpression, FilterParameters InsertMethod, InsertParameters MaximumRowsParameterName Creating PDF 417 In C#.NET Using Barcode creator for VS .NET Control to generate, create PDF 417 image in VS .NET applications. www.OnBarcode.com2 Of 7 Code Generation In C# Using Barcode drawer for .NET Control to generate, create ABC Codabar image in VS .NET applications. www.OnBarcode.comOldValuesParameterFormatString SelectCountMethod
PDF417 Maker In None Using Barcode printer for Office Excel Control to generate, create PDF417 image in Office Excel applications. www.OnBarcode.comDraw Data Matrix In VB.NET Using Barcode maker for Visual Studio .NET Control to generate, create DataMatrix image in VS .NET applications. www.OnBarcode.comPart II
EAN 13 Generation In VS .NET Using Barcode encoder for .NET Control to generate, create GTIN - 13 image in .NET framework applications. www.OnBarcode.comDenso QR Bar Code Printer In Java Using Barcode creation for Java Control to generate, create QR Code JIS X 0510 image in Java applications. www.OnBarcode.comASP.NET Pages and Server Controls
Creating Bar Code In Java Using Barcode generator for Android Control to generate, create barcode image in Android applications. www.OnBarcode.comMake Code-39 In VB.NET Using Barcode generator for Visual Studio .NET Control to generate, create USS Code 39 image in Visual Studio .NET applications. www.OnBarcode.comProperty
Encode Code 128A In Java Using Barcode generation for Android Control to generate, create Code 128 image in Android applications. www.OnBarcode.comDraw QR Code JIS X 0510 In Java Using Barcode creation for Android Control to generate, create QR Code JIS X 0510 image in Android applications. www.OnBarcode.comSelectMethod, SelectParameters SortParameterName
Description
Gets or sets the name of the method and related parameters used to perform a select operation. Gets or sets the name of an input parameter used to sort retrieved data. It raises an exception if the parameter is missing. If the EnablePaging property is set to true, indicates the parameter name of the Select method that accepts the value for the starting record to retrieve. Gets or sets the name of the method and related parameters used to perform an update operation. StartRowIndexParameterName
UpdateMethod, UpdateParameters
The ObjectDataSource control uses reflection to locate and invoke the method to handle the specified operation. The TypeName property returns the fully qualified name of the assembly that defines the class to call. Implementing Data Retrieval
The following code snippet illustrates a class that can be used with an object data source. In the example, the class does not use LINQ-to-SQL or Entity Framework; it is instead based on plain ADO.NET code. You can easily rewrite it to perform data access via the context of LINQto-SQL or Entity Framework. The Employee class being used is assumed to be a custom class created just to simplify data manipulation. public class EmployeeRepository { public static string ConnectionString { ... } public static void Load(int employeeID) { ... } public static IList<Employee> LoadAll() { ... } public static IList<Employee> LoadByCountry(string country) { ... } public static void Save(Employee emp) { ... } public static void Insert(Employee emp) { ... } public static void Delete(int employeeID) { ... } ... } 10 Data Binding
If you don t use static methods, the worker class you use with ObjectDataSource must have a default parameterless constructor. Furthermore, the class should not maintain any state. (The main drawback of static methods is that they might trip you up when it comes to unit testing the DAL, if you ever do it.) The worker class must be accessible from within the .aspx page and can be bound to the ObjectDataSource control, as shown here: <asp:ObjectDataSource runat="server" ID="MyObjectSource" TypeName="DAL.EmployeeRepository" SelectMethod="LoadAll" /> When the HTTP runtime encounters a similar block in a Web page, it generates code that calls the LoadAll method on the specified class. The returned data a collection of Employee instances is bound to any control that links to MyObjectSource via the DataSourceID property. Let s take a brief look at the implementation of the LoadAll method: public static EmployeeCollection LoadAll() { var coll = new List<Employee>(); using (var conn = new SqlConnection(ConnectionString) { var cmd = new SqlCommand("SELECT * FROM employees", conn); conn.Open(); var reader = cmd.ExecuteReader(); HelperMethods.FillEmployeeList(coll, reader); reader.Close(); } return coll; } Although it s a bit oversimplified so that it can fit in this section, the preceding code remains quite clear: you execute a command, fill in a custom collection class, and return it to the data-bound control. Binding is totally seamless. The method associated with the SelectMethod property must return any of the following: an IEnumerable object such as a collection, a DataSet, a DataTable, or an Object. Preferably, the Select method is not overloaded, although ObjectDataSource doesn t prevent you from using an overloaded method in your business classes.
|
|