In this article we shall learn ASP.NET Dynamic data. With .NET 3.5, a new cool feature is added named as Dynamic Data which is a RAD development paradigm for building functional websites.
To explore ASP.NET dynamic data and learn about its implementation.
With the rate of changes/ additions of features in the .Net framework, many of very good features don’t get the deserved attention. Especially on the ASP.NET front, there have been many such features haven’t caught the eye of developer. Dynamic data which was introduced with ASP.Net 3.5 (SP 1) is one of such cool new addition in the archery of ASP.Net.
Precisely ASP.NET dynamic data provides a framework which enables quick building of functional data driven application that are based on Microsoft ORM i.e. LINQ TOSQL or Entity framework data model. It has added smart validation and ability to change the display with templates to DetailsView, FormView, GridView, and ListView controls. As per Microsoft, the dynamic data framework enables major usability and RAD development changes to work with data model. The LINQTOSQL or EF can be registered with dynamic data to result into a fully functional web site. It supports all CRUD operations. We will explore dynamic data website with .NET framework 4.0.
Let’s start a small demonstration (employing Entity Framework) step by step.
Environment: VS 2010, SQL Server 2008 with “AdventureWorks” database
Step 1: Create a web project with template “ASP.Net Dynamic Data Entities Web Application”.
Step 2: Add an “ADO.NET Entity Data Model” into the project.
Step 3: As we are going to use “AdventureWorks” database, choose option “Generate from Database” for generating the data model from database.
Step 4: Choose the database and database connection .
Check the checkbox for saving the entity connection string in “Web.config” file.
Step 5: Select the database objects like Tables, views to be included in the model.
Step 6: Make sure the name of the data model is referred in “Global.asax”.
Step 7: Make sure that model namespace is referred in the connection string of “web.config” file.
Here we are with all prerequisites done and oh, it wasn’t too much of work. Rather is so straightforward and simple that it’s difficult to believe.
Lets run the web application and see the output.
Screen 1: This is the default page loaded into the browser when one runs the application. This lists all the tables in the data model.
Screen 2: This is the “List” page loaded into the browser when one clicks the “table” in the default page and show the records in the selected table with options for performing CRUD operations.
When one creates the dynamic data projects, visual studio different entity templates for default, edit and insert pages along-with the page templates for the same. Different templates for fields, filters are also created automatically. For scripting “JQuery 1.4.1” is also included. Templates are used in place of programming hard coded rules in controls.
ASP.NET Dynamic data framework is boon for RAD development and it’s very easy to create functional web sites. Best part is AJAX implementation is also taken care off. Also it goes hand in hand with EF or LINQTOSQL easing out the implementation with ORM’s. Validation is also taken care-off. The templates can be customized to change their appearance.
So is it a start of “TDD” – Template Driven Development?