Onlineatoz.net | ToolBox Data Control ObjectDataSource

ToolBox Data Control ObjectDataSource

ObjectDataSource Web Server Control

in ASP.NET environment,This article describes you how to work with ObjectDataSource Web Control.The ASP.NET ObjectDataSource control allows the user to get the capablities of retrieval and update data using a middle-tier object.

in DOT.Net environment, The ObjectDataSource control serves as a data interface for data-bound controls such as the GridView, FormView, or DetailsView controls, and enables those controls to display and edit data from a middle-tier business object on an ASP.NET Web page.

Receive and Modify Data

In DOT.Net environment,The ObjectDataSource control can be supporting for a three-tier architecture by providing a way for you to bind data controls on the page to a middle-tier business object. The ObjectDataSource works with a middle-tier business object to select, insert, update, delete, page, sort, cache, and filter data declaratively without extensive code.

Most ASP.NET data source controls, such as the SqlDataSource, are used in a two-tier application architecture where the presentation layer (the ASP.NET Web page) communicates directly with the data tier (the database, an XML file, and so on).

For Selecting, updating, inserting and deleting the data,The ObjectDataSource control uses reflection to call methods of a business object. You set the ObjectDataSource control's TypeName property to specify the name of the class to use as a source object.

Sorting and Paging

Sorting and Paging features has been provided with advanced by the ObjectDataSource control with the requests from a data-bound control, such as a GridView control, to the data object for processing. The source data object or the data source control itself can then sort data and return data in pages.

Caching of ObjectDataSource

by using Business object,the ObjectDataSource control can cache objects returned from them. However, you should not cache objects that hold resources or that maintain state that cannot be shared among multiple requests, such as an open DataReader object.

Filtering of ObjectDataSource

when the ObjectDataSource control receive any object of Dataset or DataTable,then the ObjectDataSource control supports filtering using the syntax of the Expression property of the DataColumn class. Filtering enables you to expose only rows that match particular search criteria, without having to re-query the data source with new selection criteria. For more information, see Filtering Data Using Data Source Controls.

Conflict Detection

When change the ObjectDataSource control's ConflictDetection property to true, you can specify that the ObjectDataSource control should include original values when calling update methods of the source data object. The original values can then be included in checks for optimistic concurrency.

To Creating a Data-Access Component
  • Create app_code folder in your application path
  • Right-click the App_Code folder, and then click Add New Item.
  • Under Visual Studio installed templates, click DataSet.
  • In the Name box, type yourObjectName, and then click Add.
  • Click New Connection and provide your connection information such as servername,and so on
  • Click Next.
  • Select the Yes, save this connection as check box, and then click Next.
  • Click Use SQL statements, and then click Next.
  • Under What data should be loaded into the table, type as: Select * from Table1
  • Click to clear the Fill a DataTable check box, and then select the Return a DataTable and Create methods to send updates directly to the database check boxes.
  • In the Method Name box, type Yourmethod.
  • Click Finish.
  • On the Build menu, click Build Web Site to make sure that the component compiles correctly.
To add a data source control to the page
  • go to Design view.
  • From the Data group in the Toolbox, drag an ObjectDataSource control onto the page.
  • On the ObjectDataSource Tasks shortcut menu, click Configure Data Source.
  • In the Choose your business object list, select your tableadapter.This is the type name (namespace and class name)
  • Click Next.
  • On the Select tab, in the Choose a method list, click MethodName(), returns DataTable.
  • Click Finish.
To add a GridView control to the page and bind it to the data
  • From the Data group in the Toolbox, drag a GridView control onto the page.
  • On the GridView Tasks shortcut menu, in the Choose Data Source list, click ObjectDataSource1, which is created by you
  • In Properties, verify that the DataKeyNames is set to yourcolumn.

  • Posted by: Admin
    Posted on: 9/14/2011 at 8:07 AM
    Categories: Asp.net
    Actions: E-mail | Kick it! | DZone it! | del.icio.us
    Post Information: Permalink | Comments (0) | Post RSSRSS comment feed