Geeks With Blogs
Frank Wang's inspirations on .NET
IEnumerable<Inspiration> inspirations = from i in DataContext.Inspirations where i.Sharable == true select i

A major upgrade to the ASP.NET Dynamic Data was released on April 8th, 2008. This release is named ASP.NET Dynamic Data Preview. ASP.NET Dynamic Data allows you to automatically render fully functional data entry and reporting pages that are dynamically constructed from your ORM data model meta-data (LINQ to SQL or LINQ to Entities object model).  In addition to supporting a dynamic rendering mode, it also allows you to optionally override and customize any of the view templates using any HTML or code you want.

The April 8 bits added quite a lot cool new features on top of the first release, including a project wizard for creating Dynamic Data Web Site in Visual Studio 2008 and a brand new web site template. Before you can play with the latest "Preview", make sure you ASP.NET 3.5 Extensions Preview installed on your computer already. 

If you have ASP.NET 3.5 Extensions Preview installed already, go ahead and download the ASP.NET Dynamic Data Preview from MSDN Code Gallery. After you have downloaded the file, unzip it to a folder on your computer, launch the dos prompt and run InstallDynamicData32.cmd or InstallDynamicData64.cmd, depending on your computer configuration. The installation takes about 4 - 5 minutes. Be patient when you see the "calling devenv /installvstemplates" message.

Installation 1

What get installed are the Dynamic Data runtime assemblies as well as versions of the System.Web.dll and System.Web.Extensions.dll assemblies that have been updated from the versions in the .NET Framework 3.5. The installation also adds C#/VB.NET templates and project wizard to Visual Studio 2008 and you can use them to create Dynamic Data Web sites easily.

To get started, open Visual Studio 2008, select File --> New --> Web Site. Note the two new web site templates installed by the new release: Dynamic Data Website(Preview) and Dynamic Data Website Wizard(Preview). The old Dynamic Data Website template (shipped with ASP.NET 3.5 Extensions Preview) is still available. Select Dynamic Data Website Wizard(Preview), name the web site NorthwindCustomers.



Click on OK. The wizard will launch the first step - generate or create a data model to be used by the web site.


I select the existing Northwind data model and click Next. The second step of the wizard allows you to choose the data objects to be added into the data model.


As you can see in the wizard, LINQ to SQL is the only Data Context Type and the drop down list is grayed out. This is because the wizard is still a preview version and there're still many unimplemented features at this point. We will go ahead and uncheck views/stored procedures/functions and check only three tables to add to our data model: Customers, Orders, Order Details.

One of the bugs I found in the preview release is specifying any Data Context Namespace will result in compilation errors. So we will leave it blank. Hopefully this bug was already submitted to Microsoft and will be fixed in the next release.

Click on Next. Now the wizard prepares all the data pages for the web site and let you review them in the next screen.


The wizard automatically creates two pages for each table: List and Details. All these pages are listed in the Available Modules panel in the wizard. You can selectively move any data page you want in your web site to the Website Structure on the right hand side. If you want to have all the pages, go ahead and click on "Add All". Click Next.


Now you are looking at the last step of the wizard, where you can optionally turn on/off any CRUD operations(insert/update/delete/select) in the data pages. The wizard is smart to know the Insert method is not applicable to "details" table due to the relationship and constraints on the tables. We will go ahead and accept all the methods and click Finish to generate the web site.

You will be asked by VS2008 whether you want to merge the code in the app_code folder. This is just a friendly warning so click Yes to close that dialog. By now, a fully functional data-driven web site has been generated without you having to write a single line of code. Before you hit F5 to run the application, let's take a look at what's under the hood. Expand the items in the Solution Explorer. You will find nothing really magical.


A LINQ to SQL data model file (dbml) was created and placed in the app_code folder along with the partial class file for the data context. This apparently serves the entire data access layer of the web site. There's a new folder named DynamicData specific to the Dynamic Data Web site. All the dynamically created ASPX pages, user controls and templates are placed in this folder. Drill down to a few ASPX pages, you will find that this version of Dynamic Data Web site works with all the native ASP.NET control (GridView, FormView, ListView etc.). You have the full control of the behavior of every web page. But as I mentioned earlier, even without any customization of the templates, the web site created by the wizard is fully functional. Run the web site. All the tables you selected are displayed in the default page of the web site.


Click on Customers to continue the navigation in the web site. You will see a GridView data bound with all the columns in the Customers table. Details, Edit, and Delete links are automatically created for each row as well. The top GridView row contains all the controls for you to insert new data.  ScriptManager and UpdatePanel are built into every page by default, so paging, sorting, row insertion, and row deletion are handled in the AJAX way natively.


Clicking on the "Details" to bring up the customer details.


Foreign key relationships are handled automatically. Click on "View Orders" in the Customer Details to view the orders of each customer.


You may not like look and feel the wizard creates for you. You may also need to add UI validations or to use different controls for specific data type. The good news is Dynamic Data Web site allows you to do all that. To get an idea of how it was all thought of, browse to the DynamicData folder in the Solution Explorer one more time and expand the FieldTemplates folder and PageTemplates folder. We will play with these templates to customize this web site in my blog post.

Posted on Sunday, April 13, 2008 5:08 PM ASP.NET Extensions Preview , ASP.NET Dynamic Data | Back to top

Comments on this post: First look at ASP.NET Dynamic Data Preview

# re: First look at ASP.NET Dynamic Data Preview
Requesting Gravatar...
Very nice Mr. Frank. I guess I won't need to write this post now!


Left by Andrew Siemer on Apr 13, 2008 5:40 PM

# re: First look at ASP.NET Dynamic Data Preview
Requesting Gravatar...
Any chance this will work with MySQL too?
Left by Remy Blaettler on Apr 29, 2008 7:41 AM

# re: First look at ASP.NET Dynamic Data Preview
Requesting Gravatar...
No Remy. Dynamic Data only works with MS SQL server because the entire data access layer depends on LINQ to SQL.
Left by Frank Wang on May 01, 2008 10:17 AM

# re: First look at ASP.NET Dynamic Data Preview
Requesting Gravatar...
It's my understanding that Dynamic Data does not yet work for other data sources such as MySQL, Oracle, etc. but will be supported in the (near) future.

Dynamic Data is built upon the Entity Framework (EF), which is much more robust that LINQ to SQL. As EF is extended to access the sources, DD will likely follow. Time will tell.

Left by Jason Kergosien on May 02, 2008 2:12 PM

# re: First look at ASP.NET Dynamic Data Preview
Requesting Gravatar...
I am wondering, other than to quickly create some internal apps / small business apps is things like this any useful for real enterprise solutions?

Was there a time you could just drap drop a data grid - connect to datasource and get done with all edit-delete-insert for an enterprise application functionality ?

simple customizations, which we always need to do,(for example, one of the details field should come from a different table, based on 2 fields in this table) would need you to learn a whole new custom methodology (FieldTemplates and PageTemplates ?) specific to this

Just thoughts..

Left by Sree on May 05, 2008 2:29 PM

# re: First look at ASP.NET Dynamic Data Preview
Requesting Gravatar...
Left by okkarmyo on Jan 15, 2010 12:08 PM

Your comment:
 (will show your gravatar)

Copyright © Frank Wang | Powered by: