Introduction to Dynamic Data Web Application Model: Part V

In previous article, we had discussed about custom data formatting feature. In this article, we will look into the customization of page layout using DynamicControl. Sometimes, we might not require using all features of Dynamic Web Application like all page operations and built-in layouts etc. So, we can use DynamicControl within controls that support templates like GridView, FormView and Repeater etc. In this sample, I am going to change complete layout of the page using Dynamic Data features.

First go to Titles.cs and add the code as shown below:

Here, I am hiding titleauthor table by using ScaffoldTable = false. Than, go to List.aspx page and make GridView1's visible is false. Add a Formview control to the page; add dynamic controls to its Itemtemplate as shown below:

Here, DataSourceID for Formview control will be the LINQ datasource declared in the page. DataField property for each dynamic control will be the property name.  By default, Mode property for dynamic controls will be Readonly [Contents will be displayed in a Label format]. So, we no need to set it in ItemTemplate explicitly. Now, run the application. The output will be like this:

Now, similarly add the same markup used in ItemTemplate for EditItemTemplate with dynamic control's Mode property to Edit as shown below:

And run the application. The output will be like this:


 
Similarly we can add same markup to InsertItemTemplate with mode as Insert.

In this way, we can customize our page by using Dynamic Data features.

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

Up Next
    Ebook Download
    View all
    Learn
    View all