What you want to see on DotNetFunda.com ?
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 8538 |  Welcome, Guest!   Register  Login
Home > Articles > ASP.NET > ASP.Net Dynamic Data

ASP.Net Dynamic Data

1 vote(s)
Rating: 5 out of 5
Article posted by Ambily.raj on 10/18/2010 | Views: 24847 | Category: ASP.NET | Level: Beginner | Points: 150 red flag


ASP.NET 4.0 supports different types of web application development and associated templates. In this article, we will talk about the ASP.Net Dynamic Data and how we can create a fully functional web application without writing a single line of code.

Introduction

ASP.NET 4.0 supports different types of web application development and associated templates. The different ways of creating web applications are

  • ASP.NET Web Forms: Normal web application with set of Web forms
  • ASP.NET AJAX: Web application based on Ajax technology
  • ASP.NET MVC: Web application based on Model View Controller Pattern.
  • ASP.NET Dynamic Data: Web application which dynamically creates the pages.

In this article, we will talk about the ASP.Net Dynamic Data and how we can create a fully functional web application without writing a single line of code.

Pre-requisites

ASP.Net Dynamic Data is introduced as part of Visual Studio 2008 SP1 and it is available in Visual Studio 2010.

ASP.Net Dynamic Data

ASP.Net Dynamic Data is used to develop data driven web applications in thinking speed. If you have a requirement to develop a data driven web application with less time, then Dynamic Data is the best solution for the same. As the pages are rendering dynamically at runtime, there is a small performance impact in the execution of the web site. This can be used along with normal web applications, MVC sites or Ajax web sites.

For an instance, if you have an ASP.Net web application, which need to display Dashboard, then use the ASP.Net Dynamic Data concept to generate only the Dashboard page. ASP.net Dynamic Data allows the fast development of Data driven web pages with full support for CRUD operations, paging, sorting and linking.

Have a Look

ASP.Net Dynamic Data have two different project templates; one for supporting the Entity framework and another for LINQ to SQL classes. 



 
ASP.Net Dynamic Data Entities Web Application: this template uses Entity Framework for connecting to the database.

ASP.Net Dynamic Data Linq to SQL Web Application: this template uses LINQ to SQL classes for connecting to the database.

For our sample, I am going to use the ASP.Net Dynamic Data Linq to SQL Web application template [Template names will be different in Visual Studio 2008 SP1]. Following is the solution structure of the ASP.Net Dynamic Data web application. We will look into each item in detail latter.


LINQ to SQL Classes

Now, add the LINQ to SQL Classes for defining the connection with the database. Right Click on the project name, select Add New Item. From the Add New Item Window, Select the LINQ to SQL Classes item.  


Define the database or use existing database connection from server explorer. Drag and drop the tables, views and stored procedures to the design surface. 

 

After that, open the designer.cs file associated with the LINQ to SQL classes.



Note the data context name. In the above example, it is NorthWindDatContext.

Now, open the Global.asax file and uncomment the highlighted line.



 
Change the typeof(YourDatContextType) with the created DataContext Name, that is NorthWindDataContext. Also change the ScaffoldAllTables=false to ScaffoldAllTables=true.

DefaultModel.RegisterContext(typeof(NorthWindDataContext), new ContextConfiguration() { ScaffoldAllTables = true });


ScaffoldAllTables= true means, we need to display all the selected tables in the web application. In our application, we may have a table used for defining the Many to Many relationships between two tables. This table may not be displayed in the UI.


Now, our site is ready and fully functional. It will support all CRUD operations on the selected tables.


Built-in home page look like


Our application will support display of database values, updating the values, inserting new values to database and also deleting existing records. The pages for insert, display and update will dynamically create using the page templates and field templates. We will look into different templates in the next article.


Following figure shows the dynamic display table data with sorting, paging and reference links for foreign key fields. Also, it supports filtering of table data using enumerable values and foreign key values.


 
Click on the Details link to view the row details.

 
Filter the data using Foreign Key or Enum values.



Click on the Insert new Item link below the grid for inserting a new item to the table.

 
Click on the Foreign key links to open details of the related items


Conclusion

In this article we discussed about the new ASP.Net Dynamic Data and how we can create a fully functional data driven web site with zero lines of code. We will look into the ASP.Net Dynamic Data customization in next article.

 

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About Ambily KK

Experience:9 year(s)
Home page:http://ambilykk.com/
Member since:Tuesday, May 18, 2010
Level:Silver
Status: [Member] [Microsoft_MVP] [MVP]
Biography:I have over 9 years of experience working on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Office Open XML, Azure, Visual Studio 2010. Technology adoption and learning is my key strength and technology sharing is my passion.
 Responses
Posted by: SheoNarayan | Posted on: 18 Oct 2010 01:19:56 AM | Points: 10

Small and nice article, very good presentation style. Keep it up Ambily !

Regards

Posted by: Vpramodg | Posted on: 18 Oct 2010 03:20:49 AM | Points: 10

hai

Thank you for submitting such good articles.
pramod.v.g

Posted by: Ambily.raj | Posted on: 18 Oct 2010 08:54:18 AM | Points: 10

Thanks

Regards
Ambily

Posted by: Goodness47 | Posted on: 31 Dec 2010 12:36:07 AM | Points: 25

Thanks A lot For a good article

Posted by: Ashuthinks | Posted on: 17 Sep 2012 09:37:33 AM | Points: 25

need your help on data dynamics
in dropdown all the FK column values are coming up if i want only value who's name is 'Ashish'
then where i can write ? and where should i write that query?
in .dbml file ?
please help i'm newbie in data dynamics
ashuthinks[at]gmail.com


Posted by: Adelr5 | Posted on: 28 Oct 2012 04:32:00 PM | Points: 25

How can I (Update/insert/delete) in views ... every time I add views to the table they dont show edit nor delete ?
any one can help?

best regards

>> Write Response - Respond to this post and get points
Related Posts

Using this control, in ASP.NET one can upload files very easily. Though, it has few restrictions, yet I would say it is a fantastic Control.

We can direct select,update and delete the values of the database by Grid View using Linq Data Source.

This article describe how to create Roles based sccurity using Forms Authentication in easy to follow steps.

How to upload a image and store in a database

In This Article you can Know how to store a Global SqlConnection

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 5:59:35 PM