ARTICLE

Creating a Dynamic Data Web Site in ASP.NET 4.0

Posted by Amit Patel Articles | .NET 4.5 July 05, 2012
You can create Dynamic Data Web sites in Visual Studio by using ASP.NET Dynamic Data templates.
Reader Level:
Download Files:
 


Steps to create a new ASP.NET Dynamic Application with Linq to SQL.

Step 1: To create a new web application and application type will be using an ASP.Net Dynamic Data Linq to SQL Web Application.

FirstStep.png
 
Step 2: Now we'll add a database toe the web application. I have added a MDF file in the App_data folder.
 
step2.png

Step 3: Now we'll add LINQ to SQL Classes.

step3.png
 
Step 5: Now we will add the requied tables in the DBML file.

step4.png
 
Step 6: Now when you run your application you will get the following error:

step5.png
 
To resolve the error we need to make some changes in the Global.asax file.

By default this line is commented:

DefaultModel.RegisterContext(typeof(YourDataContextType), new ContextConfiguration() { ScaffoldAllTables = false });

we need to add our entity context there and ScaffoldAllTables should be true.

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

Step 7: Now when we run our application the output will be:
 
step6.png
You will see three tables in the above image. The Customer and Store tables can accept null value for their colums. But the Employee Table will not accept a null value because we have add a null contraint to all columns.

step7.png
 
The conclusion is that we can easily create Data Dynamic applications.

Login to add your contents and source code to this article
comments
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts