Random thoughts of wisdom - the personal blog of Michael Holm Andersen

Using ItemCreated and DataBound events in DetailsView

GridView and DetailsView are some of the many new additions to ASP.NET v2.0. As there are tons of articles about GridView and how to do all kinds of tricks with this new control, however when it comes to the DetailsView control it's a different story.

So after searching the 'net and found very few articles about the DetailsView control .. I decided to write my own article (well .. piece of code actually!), which shows how to use the ItemCreated and DataBound events to change values, hook in to TemplateFields and other fun stuff - Enjoy! :-) 

Know your data structures!!

MSDN has a great article about data structures, some of which are included in the .NET Framework Base Class Library and some we can build ourselves - check out this great and in-depth article.

ObjectDataSource In Depth

I've mentioned the built-in DataSet feature in Visual Studio 2005 before, which through a ObjectDataSource will take care of the CRUD operations (create, retrieve, update and delete) of your domain objects.

If you're using the DataSet feature you might take a closer look at this article at CodeProject:

New Web Site Project in Visual Studio 2005

Web Application Projects provide a companion web project model that can be used as an alternative to the built-in Web Site Project in Visual Studio 2005. 

The new model is more feature rich than the built-in Web Site Project and offers the following functionality:

  • Team Build Support with VSTS
  • Strongly-typed access to resources defined within the App_GlobalResources directory
  • Custom Build Tool Action support
  • Edit and Continue support

As I see it, the Edit and Continue feature is by far the most interesting, allowing the programmer to debug, edit code and continue execution.

ORM, Code Generation and stuff..

Wouldn’t it be nice, if there were tools that (given a database and a table in that database) did the whole bit of magic and generated a C# solution, which will have a GUI for all the basic CRUD operations along with the DAL? I bet that would be nice!! Well, we are not alone; there are so many people who have thought of this before us... Check out this CodeProject article about Code Generators, ORM mappers or what-ever you prefer to call them.

Building a DAL in VS 2005

Scott Guthrie has posted a great article about Building a DAL using Strongly Typed TableAdapters and DataTables in VS 2005 and ASP.NET 2.0 - This is cool stuff and can really safe you some time.

The DAL class can also be used together with the ObjectDataSource control to support native databinding within VS.NET (just like SqlDataSource), supporting sorting, pageing and native CRUD operations.