This project is read-only.

The GenericDataSource for ASP.NET 3.5

Project Description

The ASP.NET Generic Data Source Control may be used as the Data Source for any ASP.NET data-bound controls: GridView, ListView, FormView, DropDownList, DetailsView,... delivering true flexibility, separation of concerns and real support for the ASP.NET web development

Why to use the ASP.NET GenericDataSource?

  • it may be the DataSource for any ASP.NET data-bound control: GridView, ListView, FormView, DetailsView, DropDownList, BulletedList, Repeater, etc.
  • it is design for RAD (Rapid Application Development), but with respects to best practices and proven standards: it may be used for very simple websites, but also for the huge enterprise web applications.
  • no need for additional settings over the data-bound controls; the GenericDataSource works just as any other ASP.NET DataSource, therefore it may successfully replace the ObjectDataSource, LinqDataSource or EntityDataSource.
  • no need for any other DataSource configuration, like EntityTypeName, SelectMethod, InsertMethod, SelectCountMethod,; it is very simple and straightforward to use the GenericDataSource: just implement the handlers that you need: Select, Update, Insert and Delete.
  • it has great support for paging and sorting; it naturally works with GridView paging and sorting, but also with ASP.NET 3.5 DataPager.
  • since it doesn't require any configuration, the GenericDataSource is very flexible when it comes to code refactoring (as opposite to the nightmare of refactoring when working with the ObjectDataSource)
  • it is designed for performance, since it doesn't use any reflection.
  • real support for optimistic concurrency.
  • developers really enjoy ASP.NET web development.

How to use the GenericDataSource?

Is as simple as this:

<%@ Register Assembly="GenericDataSourceControl" Namespace="GenericDataSourceControl" TagPrefix="cc1" %>

...

<cc1:GenericDataSource ID="GenericDataSource1" runat="server"
  OnExecuteSelect="GenericDataSource1_ExecuteSelect"
  OnExecuteInsert="GenericDataSource1_ExecuteInsert"
  OnExecuteUpdate="GenericDataSource1_ExecuteUpdate"
  OnExecuteDelete="GenericDataSource1_ExecuteDelete">
</cc1:GenericDataSource>

...


<asp:GridView ID="GridView1" runat="server" DataSourceID="GenericDataSource1" AllowSorting="True" AllowPaging="true" DataKeyNames="ID" PageSize="4">
...
<asp:GridView>


... performing SELECT
protected void GenericDataSource1_ExecuteSelect(object sender, GenericDataSourceControl.GenericSelectArgs e)
{
    //Just setup the DataSource
    e.SetData(data); //data may be whatever IEnumerable/IQueryable 
}


..performing an UPDATE with optimistic concurrency
protected void GenericDataSource1_ExecuteUpdate(object sender, GenericUpdateArgs e)
{
    //Get the ID Entity key value; this value must be set on the GridView.DataKeyNames
   var updated = e.GetDataItem<T>();
   var original = e.GetOldDataItem<T>();

    //submit the change back to the database:
    ...Update(updated, original);
}

Last edited Jun 16, 2010 at 10:55 AM by adyi04, version 11