Shahar Gvirtz's Weblog

Dynamic Data Web Application - Part 1

ASP.NET 3.5 Extensions is a package of new controls and tools that improve the existing ASP.NET 3.5.
One of the interesting (and time-saving) features, is the Dynamic Data Controls. Dynamic Data Controls can be used to build easily, almost without writing any line of code a complete data-driven Web Application.
The controls cover the common things that developers use when build a web application which work with DB -  view information, delete, update, view detailed information, add new data etc.

For example, let's say we need to build a management panel for DB. First, we (or the DBA) build the DB, and then, we create a web forms for managing this DB. Let see how can I do it simply with Dynamic Data Web Application in 5 minutes.

In this article, you won't see any line of code!
The site we build is actually based on the Dynamic Data controls built-in template, and doesn't include any custom logic.
In the real world, we may want to add our logic, and in the next part of the article you'll see how to do this.

Step 1 - Create a new Dynamic Data Web Applicationimage

After you downloaded and installed the ASP.NET 3.5 Extensions, you open your VS 2008, and create new Dynamic Data application. Note that you must use .NET 3.5 for this (if you use .NET 2.0, maybe you want to check ASP.NET Futures July CTP which works in .NET 2.0)

 

 

Step 2 - Add you database to the App_Data folder

In this example, I use the Northwind database.

Step 3 - Add LINQ to SQL Classes Fileimage

Add new item to your project, I called in "db". The Dynamic Data Controls based on LINQ to SQL Object Mapper, and use it to get and work with your DB. Drag from the Server Explorer the items you want that Dynamic Data will work with. I added all the tables in Northwind DB.

 

 

Step 4 - Edit your web.config file

If you don't want to customize the Dynamic Data site, and you want to create fully data driven application without writing even one line of code (great for demos), just go to web.config to line 130 and set enableTemplates property as "true" and set the dataContextType to the name of our LINQ to SQL classes name:

<dynamicData dataContextType="db" enableTemplates="true">

In this line we set Dynamic Data to work with the default templates (you can find them in App_Shared folder).

Step 5 - Run the Application

image

What we get by default?
The default template of the Dynamic Data site stored in the App_Shared folder. The web forms use the new controls - DynamicGridView (which render on client side like a standard GridView), DynamicFormView etc.

In the main page we can se list of all our tables that are in the LINQ to SQL. The LINQ to SQL include the full database schema, which means that all the relationships can be used it the Dynamic Data Site.
For example, take a look in the Products page. you see a list of all the items in GridView, you imagecan select and see details in the DetailsView in the bottom of  the page, you can sort, edit and delete.
But, you can also see that the last 3 columns, are a links to another pages that include the categories, the order dentils and the supplier information. In the database schema, this columns include only the ID of the category, the ID of the Supplier. The DynamicData Controls, show instead the ID, a link to page with the category details or the supplier details.  imageThis feature based on the LINQ to SQL that create objects from the tables, with association that make it possible for DynamicData Controls to link the relevant page instead show numeric ID.

Summary

In this part, you see how to create a simple data driven web application without write code.
In the next part, we'll see how we can customize the application. change the style, remove and add columns from the view, and add logic.

 

Shahar Gvirtz.

Comments

Arie said:

So, is this the same as Blinq? (www.asp.net/.../blinq)

# January 27, 2008 3:00 PM

Eugenio Estrada said:

Hi Shahar,

Hehehe, we're the youngest of this community, hehehe.

How many time are you programming?

Best regards,

Euge

# January 27, 2008 4:53 PM

shahargs said:

Arie, I didn't work with BLINQ, so I don't know for sure.

Euge, I'm programming in the last 7 years (of course, not in .NET all this time).

Shahar.

# January 28, 2008 1:17 AM

shahargs said:

Arie, I checked a little, and looks that blinq isn't active project (working with May 2006 LINQ CTP...).

Maybe this project is the base of Dynamic Data, but i don't know this for sure.

Shahar.

# January 28, 2008 1:31 AM

Lilach said:

Small question,

I installed ASP.NET in the 3.5 Framework SP1. Is that enough or do I need to install the extention too?

at the moment I don't have the option of new Dynamic Data Web Application in the visual studio. I was wandering if there is a problem with the SP1 installation or am I missing something.

thanks.

Lilach

# September 3, 2008 7:47 AM

Sam Schutte said:

Thanks!  Great article!

# November 14, 2008 2:29 PM

Nick said:

Thanks Shahar, Great tip!

Nick

<a href="http://www.amazooz.com">www.amazooz.com</a>

# December 3, 2008 3:02 AM

falak said:

hi Lilach,

I think so yo have to install VS 2008 SP1 also to get dynamic data website option

Thanks

Falak

# December 4, 2008 10:36 AM

gprodhon said:

Is there any Part 2  ??

Thanks.

Gilles

# July 31, 2009 10:07 AM

structured settlements said:

Thanks for sharing

# November 23, 2009 2:26 AM

migraine treatment said:

this was written so clearly, even a beginner like me could understand it.  thanks for your help.  i look forward to trying it out.

# December 1, 2009 3:24 AM

minhaj said:

u r too good.keep helping us

# February 22, 2010 1:06 AM

Dobbs said:

The only step I can't figure out is step 2 - how to add your database to the App_Data Folder.  Do i do this by right clicking on the App_Data folder and choosing add existing item?  Do i do this by actually moving the northwind database into the app_data folder in windows explorer?

Thanks

# May 9, 2010 7:04 AM

Ahmadreza's notes said:

WEBCAMPS Sydney Day 1 - Part 1

# June 2, 2010 8:07 AM

Ahmadreza's notes said:

WEBCAMPS Sydney Day 1 - Part 1

# June 2, 2010 8:16 AM

Jovan said:

Great, great article.. You were very, very helpfull.. Tnx again...

# June 9, 2010 1:37 PM

Kids Shirt said:

"my God, i imagined you have been going to chip in with some decisive insght on the end there, not depart it with ‘we go away it for you to decide’"

--------------------------------------------

my website is  

http://chineseastrology.us

Also welcome you!

# November 16, 2010 1:19 PM

zero skateboards logo said:

A mutual pal stated I really should appear have a look at your website. Glad I clicked on the link! I like how you actually focus and get on the bottom line but can  you run via that last portion once more? Just a little?

--------------------------------------------

my website is <a href="zeroskateboards.org/.../a> .Also welcome you!

# December 3, 2010 10:31 PM

korean dictionary said:

Hey extremely good weblog!

--------------------------------------------

my website is  

http://ogre-store.com

Also welcome you!

# December 6, 2010 2:23 AM

top 10 ipad accessories said:

The first step is as good as half over.

-----------------------------------

# December 20, 2010 6:35 AM

ipad application said:

-----------------------------------------------------------

"Hi I discovered this internet site by mistake. I was researching Google for Registry pc software program that I had currently purchased when I came upon your web site, I must say  your site is truly cool I simply adore the theme, and this posts title, Rainbow & Beyond | July Newsletter from the Field. Its wonderful! I don't have the time at  the present moment to fully read your web page but I have bookmarked it and also signed up for your RSS feeds. Smile I will be back soon!!!! Keep up the great  blog!"

# January 9, 2011 2:59 PM

bayan said:

Awesome blog Adam!! deneme linki  I saw you all in Buffalo and the show was incredible,  <a href="http://www.otellerx.com" rel="nofollow" title="oteller, otel antalya antalya otelleri">oteller</a>

# February 20, 2011 10:45 PM

Use Net | AllGraphicsOnline.com said:

Pingback from  Use Net | AllGraphicsOnline.com

# March 20, 2011 3:27 PM

Flour Mills said:

I find your website on google, it proved to be useful for me , i like it very much !

# June 13, 2011 5:05 AM

Jess Salmon said:

The incredibly heart of your writing while appearing reasonable originally, did not settle correctly with me personally after some time. Someplace throughout the sentences you truly managed to create me a believer but only for a short although. I nevertheless have got a dilemma with your leaps in logic and you may do nicely to fill in those breaks. In case you really can accomplish that, I could surely be fascinated.

# July 1, 2011 5:56 AM

Jess Salmon said:

Your site is actually great ... carry on the great effort!

# July 5, 2011 7:47 AM

Bandages said:

I feel delighted to read such a good post, I would like to thank the Author for this marvelous efforts.this post is good in regards of both knowledge as well as information. Thanks for the post.

# October 22, 2011 3:56 PM

中古車査定 said:

I feel delighted to read such a good post, I would like to thank the Author for this marvelous efforts.this post is good in regards of both knowledge as well as information. Thanks for the post.<a href="www.pmgt.co.jp/.../a>

# November 20, 2011 6:35 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)