Mohammed Atef’s Technical blog

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

Advertisements

May 10, 2011 - Posted by | .Net 2010 | , , ,

1 Comment »

  1. Hey, I think your blog might be having browser compatibility issues.
    When I look at your website in Opera, it looks fine but when opening in Internet Explorer, it has some overlapping.
    I just wanted to give you a quick heads up!

    Other then that, very good blog!

    Comment by stop snoring device | June 19, 2013 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: