Introduction to Dynamic Data Web Application Model: Part II

In previous article, we had gone through basics of Dynamic Data template. In this article, we will look into customization of it as per our requirements. I am going to use same sample of previous article. We will first start with URL routing followed by Inline editing.

Open the application, and run it. The urls of the title table will be like this by default:

titles/List.aspx [For displaying], titles/Insert.aspx [For Inserting]….It means, default url format will be {table name}/{Action name}.aspx. In some cases, we might need to change the url name with a meaningful name.

There are three ways of URL routing:

  1. Table Specific - This routing will be based on table name irrespective of action.
  2. Action Specific - This routing will be based on action like List, Insert, and Edit etc irrespective of table name.
  3. Table & Action Specific - This routing will be based on both table name and action being performed.

We will dig each of them with an example. Global.asax.cs will be used for URL routing.

In Global.asax.cs, we can find below lines of code:

This statement, will format the URL in tablename/actionname.aspx. So, we will change it here as per the required format:

Table Specific:

In this, routing will be done based on table name. I will make titles table url should have a demo appended to its url and titleauthors table url should have only table name with page name. Finally, the code will be like this:

If the table is Titles and action is List/Details/Edit/Insert than URL should be titles/{action}demo.aspx.

Action Specific:

In this, routing is based on only action irrespective of table. I will make action List should have Sample appended to its page name and action Edit should have EditSample appended to its page name. Finally, the code will be like this:

Table & Action Specific:

In this, routing can be done specific to a table name & action.  I will make for action List and table Titles, the page name should be ListTitleList.aspx and for action List and table TitleAuthors, the page name should be ListAuthorsList.aspx. Finally, the code will be like this:

 

So, based on table name or action we can do a URL routing. Now, we will look into inline editing.

Normally, there are two ways to edit the data:

  1. General Edit - View, insert or update the data in different pages.
  2. Inline Edit - View, insert or update the data in a single page.

Upto now, we are using general edit. Sometimes, it may require doing all edit/insert/update operations in a single page.

Goto global.asax.cs, comment table & action specific code and uncomment the routing code to ListDetails.aspx page as shown below:

Now run the application, output will be like this:

Above specified all routing mechanisms will be applicable for this Inline Edit also.

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.


Similar Articles