TechBubbles

Creating a Dynamic Data web site using Scaffolding

Introduction

This post explains how to create a basic Web application that uses ASP.NET Dynamic Data. ASP.NET Dynamic Data provides the Web application scaffolding that enables you to build rich data-driven Web applications.

scaffolding is mechanism that enhance the functionality of the existing ASP.NET Framework by adding the ability to dynamically display pages based on the data model of the database.

Creating a Dynamic Data Web site

We can use web site template to create a Dynamic Data Web Site.

The following steps explains the procedure

  1. Start Visual Studio 2008.
  2. Go to File menu, click New Web Site, New web site dialogue box is displayed.

Dynamic1  

3. Select the Dynamic Data Web Site Template from the above dialogue box.

4. In the Location box type the name for the web site and click ok.

Adding the Data to Web site

Add a database to the project  and create the database model

To Add the database file to project.

1. In solution explorer, Right click the App_Data folder  and click Add Existing  Item.

2. Enter the AdventureWorks_Data.mdf name location file in location box.

 

The next step is create the Data model

To create the data model using LINQ to SQL

1. Right click the solution explorer and then click Add New Item.

Linq-Sql

 

2. Click Add the following dialogue will appear

ORM

Object Relational Designer is displayed

In the O/R Designer , Click the Server Explorer link

3. From Database Explorer, under data connections, expand the database file node and then table node.

4. Drag all tables into the O\R designer. Each table represented as entity.

Register the data context

1. Open the Global.asax file.

2. model.RegisterContext(typeof(AdventureWorksDataContext),
    new ContextConfiguration() { ScaffoldAllTables = true });

3. The above line in Global.asax file registers the LINQ to SQL data context for Dynamic data web site.

Testing  Dynamic Data web site

1. In Solution explorer, right-click the Default.aspx page, and then click on view in browser.

2. The following screen shows the browse page

Dynamicdatasite

  3. Using the above site you can add/edit/delete the data in a particular table.

Related Posts:

5 comments

5 Comments so far

  1. Tech Bubbles » ASP.NET Dynamic Data Overview August 28th, 2008 12:13 am

    [...] The sample web site application to develop using ASP.NET Dynamic data  [...]

  2. DotNetKicks.com August 28th, 2008 11:20 am

    Creating Dynamic Data Web site using ASP.NET…

    You’ve been kicked (a good thing) – Trackback from DotNetKicks.com…

  3. Shahid Riaz Bhatti October 11th, 2008 7:34 pm

    Very nice written article. I have already seen some webcast realted to this. I need to know that at the moment we are just adding/editing and delete record using scaffolding. What if I want to make a complete web site using scaffolding? I want to impliment my business checks etc.. Is it possible?

  4. kumar June 11th, 2009 4:48 pm

    very nice article thanks

  5. Puneet Arora August 21st, 2009 8:24 pm

    Dear ,

    Do you think this concept can be used for production .I mean real life cases to build complete solution .

    What do you think , can any throw some real light on this … scaffolding concept .

Leave a reply