ASP.NET 2.0 Seminar Day 2

Well … today has been a more interesting day. We spent it on Data Access where much change has come about indeed !

Starting off, then, with .. Declarative Data Access:

Apparently, in Visual Studio 2005 and in ASP.NET 2.0, there’s a bunch of new components called Data Sources. There’s an Sql Server data source, Xml data source, Object data source etc. You can actually drag those components onto your page, and using a little Wizard (small but EXTREMELY functional ), configure a query to be executed on the server, and generate insert, update & delete statements automatically.

As you can understand, a Data Source is nothing but a wrapper around say, an SqlConnection, SqlCommand, DataAdapter and the boring code we always have to write to get a DataSet back.

So, say you’ve a DataGridView component in your page (the DataGridView is an upgrade of the well-known DataGrid, I’ll get to that shortly). You’ll notice in the properties that there is a new item, called DataSourceId. There, you type-in the Id of the DataSource control .. et voila! You’ve just populated a DataView with data from a Database, into an updateable DataView, with 10 clicks of the mouse.

I must admit that this complete lack of code-writting is not my cup’o'tea. However, I must also admit that it saves A LOT of time, it’s efficient (!!!), and .. it works :)

Another control pair that will surely get loved is the Repeater, coupled with a ContentPager - oh yes .. mommy M$ has given us a component that auto-magically pages your data view components. I filled a Repeater with a DataSource, added a ContentPager, and it works, brilliantly. For those of you who are now wondering “what about the view state?“, I should point out that this is a winning combination, since it doesn’t use the view state at all ! :D … I can see a love affair here boys … :P

Anyhow, in more code-oriented topics, now, you can query the system for the various Data Providers present on the machine (OleDb, ODBC, etc. ). In practical terms, that would be a first step if you were to make your data access code more generic. I personally like that sort of thing, componentizing functionality, where I only code against the interfaces, and use class loading to create actual provider instances.

The practical was all about creating a master-detail view page, using a couple of Data Grids & two Data Sources, where the second grid was being filled-up from a query that used a value from the first grid as a parameter. Interestingly, you can do that in less than five minutes, just by clicking around in the properties … you know my feelings on the subject :)

The next session was called “Application Services”, which is admittedly a bad name. It was about various Counters (statistics) you can use, that the new ASP.NET Framework provides for free - actually, you can count even button clicks on a page but I’m not sure about the quality & breadth of the details you get backfrom those stats ). Next, the SiteMap data source, where by using an Xml file, you can create a Site Map by Data Binding almost any control to the Xml. I saw it working with a Tree View and Menu controls.

It seems that Microsoft has decided to reduce the amount of code the developer has to write for common tasks in a web app like data access & display, navigation, authorisation etc. etc. The guy said that the objective was to reduce the amount of code you have to write by 70% … well, I must admit that it is close to that, really.

Tommorow we’ll be spending time with Web Parts, Security and general ASP.NET configuration.

TTFN (ta-ta-for-now)

O;]

Comments are closed.