SIGN UP MEMBER LOGIN:    
ARTICLE

Introduction to Dynamic Data Web Application Model: Part I

Posted by Sateesh Arveti Articles | Visual Studio .NET January 15, 2009
This article gives an introduction to Dynamic Data Web Application Template
Reader Level:

Visual Studio 2008 with SP1 introduced a new template for creating data driven web sites without any coding. There are two templates used for creating web sites within a short span of time. I am going to discuss about Dynamic Data web Application template in this article. In coming articles, we will look into Dynamic Data Entities web Application model.

Introduction:

Most of the ASP.NET applications will interact with a database like SQL Server.  90% of our code will be retrieving/updating data of a database. Before knowing the greatness of Dynamic Data template, we need to have a look into the steps; we follow for developing any web sites:

Generic steps for developing a Web site:

  1. First, we will get a list of tables for retrieving/updating the data.
  2. Create the pages for displaying, inserting, updating and deleting the data.
  3. Write code for saving it back to database.

Most of our code is handling data present in the database. So, Microsoft came up with a template that will handle most of the data handling tasks. I am going to use VS 2008 with SP1 and SQL Server 2008 Express Edition with Advanced Services for these demos.

Open your Visual Studio, select New Project --> Web --> Dynamic Data Web Application and give name as DynamicDataSample1 as shown below:

We will have a look into the files that are created for us by this template: 

We can see there are page and field templates in it. These templates will be used for displaying/editing/inserting data irrespective of the tables.

Now, we will look deep into these templates:

Page Templates:

Details.aspx: This page is used to display the contents of a table in a detail view using controls like textbox, checkboxes etc…

Edit.aspx: This page is used to edit the contents of a table.
Insert.aspx: This page is used to insert new records into the table.
List.aspx: This page is used to list contents of a table in a gridview.
ListDetails.aspx: This page is used to list contents of a table with an inline edit/insert capability.

FieldTemplates:

This are used to set properties for the controls present in Page templates. Whatever we change here, it will applicable for all the pages using this field in it. For example, if we change a property for Text.ascx control; than it will reflect in all pages using that. We will look into these templates deeply in coming articles.

Let's start with a sample, create a connection to Pubs Database in Server Explorer as shown below:

Now, add a LINQ to SQL class to the solution and name it as Pubs.dbml as shown below:

Now, drag and drop title and titleauthor tables from server explorer onto design view of pubs.dbml as shown below:

Go to Global.asax.cs and uncomment model.RegisterContext statement and make ScaffoldAllTables = true and name of data context as PubsDataContext[Which we got from Pubs.cs of Pubs.dbml] as  shown below:

It's ready to run it without a single line of coding. Make sure Default.aspx is a Startup page. This page will list the tables. Select a table that will direct you to a page, where we can edit/delete/insert records. This template uses AJAX features also in page design. So, we no need to bother about the User Experience.

I will end up the things here. In coming articles, we will look deep into the customization of this template. I hope this will be helpful for all.

Login to add your contents and source code to this article
share this article :
post comment
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor