Link Asp.net Dynamic Data Entity item to customized web pages
Introduction
When we build ASP.NET applications that sit on top of a data store of some kind, there are always a set of common tasks that we need to provide a UI for. Just a few of these patterns are listed here:
Entity Lists — Display a list of rows in a table.
Detail Form — Displays the details of a single entity.
Edit Form — Enables the user to edit the details of a single entity.
Create — Adds a new entity to a list.
Delete — Deletes an entity from a list.
Navigation — Provides Search, Filter, Sort, and Paginate lists of entities.
Problem definition
sometimes we need to link one of entity list to another customized screens we have implemented before, so how we can do this task?
Solution
Here we are going to link one of listed entities in web application entities list to another existing or customized page throw the binding event of Grid View of listed entities.
so if we have assumed that the entity name called Site and the customized page called siteslist.aspx, we can write the following lines of codes to redirect to this customized page when user select Site entity from entities list
1: protected void Menu1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
2: {
3: if(e.Row.RowIndex!=-1)
4: {
5: if (((System.Web.DynamicData.DynamicHyperLink)e.Row.Cells[0].Controls[1]).Text == "Site")
6: {
7: ((System.Web.DynamicData.DynamicHyperLink)e.Row.Cells[0].Controls[1]).NavigateUrl = Request.Url.ToString().Trim().ToLower().Replace("default.aspx","SitesList.aspx");
8: }
9: }
10: }
I think these few lines of code is very clear as shown above i have get the grid view row that has Site entity and replaced it’s NavigateUrl with the new siteslist.aspx page.
Note, there is very important note that you should use customized screen like siteslist.aspx which note linked to master page if this page in the same web application else you can use any kind of web pages.
I Hope that helped
No comments yet.
Leave a Reply
-
Archives
- May 2011 (2)
- January 2011 (2)
- December 2010 (1)
- September 2010 (8)
- August 2010 (1)
- March 2010 (1)
- November 2009 (1)
- October 2009 (3)
- September 2009 (2)
- August 2009 (1)
- July 2009 (7)
- June 2009 (10)
-
Categories
-
RSS
Entries RSS
Comments RSS

