Buy Questpond's video subscriptions on huge discount .
DotNetFunda.com
Online: 2076
Home> Articles> ASP.NET>
  • Wait Loading ...

ASP.Net Dynamic Data

Ambily.raj
Posted by in ASP.NET category on for Beginner level | Points: 150 | Views : 48150
If you found plagiarised (copied) or inappropriate content,
please let us know the original source along with your correct email id (to communicate) for further action.
Rating: 5 out of 5
1 vote(s)

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.

About the Author

Ambily.raj
Full Name: Ambily KK
Member Level: Silver
Member Status: Member,Microsoft_MVP,MVP
Member Since: 5/18/2010 1:05:25 AM
Country: India
Thanks Ambily K K http://ambilykk.com/
http://ambilykk.com/
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.

Login to vote for this post.

Comments or Responses

Posted by: SheoNarayan on: 10/18/2010 | Points: 10
Small and nice article, very good presentation style. Keep it up Ambily !

Regards
Posted by: Vpramodg on: 10/18/2010 | Points: 10
hai

Thank you for submitting such good articles.
pramod.v.g
Posted by: Ambily.raj on: 10/18/2010 | Points: 10
Thanks

Regards
Ambily
Posted by: Goodness47 on: 12/31/2010 | Points: 25
Thanks A lot For a good article
Posted by: Ashuthinks on: 9/17/2012 | 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 on: 10/28/2012 | 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
Posted by: Jayakumars on: 4/16/2015 | Points: 25
hi
Ambily KK

Good Post

can you send this source my EmailId : Kumaraspcode2009@gmail.com.

This is comfortable in vs 2012

Login to post response

Comment using Facebook(Author doesn't get notification)

AltStyle によって変換されたページ (->オリジナル) /