Last post Sep 08, 2010 04:28 PM by jjfrick
Aug 02, 2010 08:04 AM|jjfrick|LINK
I'm using vs2010, EF. I have a left column simular to a navigation area and I'm trying to figure out a way to display the FK links that appear at the end of a list as columns, in my navigation area. One thought was to place a duplicate table in the navigation
area and hide all the columns except for the FK links. Is there an easier way to accomplish this.
Aug 02, 2010 09:22 AM|sjnaughton|LINK
Hi Jeff, not sure what you want?
Aug 02, 2010 09:25 AM|vinay13mar|LINK
Your question is not much clear can u plz explain it more...
Aug 02, 2010 10:34 AM|jjfrick|LINK
I will use an example since my database wouldn't be forum-friendly. Say you the following tables:
Employee, Department and Manager
Now lets say I have a search function to search the employee table and I searched for last name "Smith".
I now have a list of all the "smith's" found in the employee table. Maybe a row looks something like this:
EmployeeID, FirstName, LastName, Status, StartDate, DEPARTMENT, MANAGER
(DEPARTMENT & MANAGER are FK links and are the last columns in the table)
What I'm trying to do is hide DEPARTMENT and MANAGER from the table and instead show DEPARTMENT and MANAGER using css or something to show these links on the left "navagation" menu, like this:
Aug 02, 2010 11:51 AM|sjnaughton|LINK
Hiding the columns is easy and so is generating the links and if the page you are doing this on is a Details no problem see my post here SiteMapProvider for Dynamic
Data (.Net 3.5 SP1 and .Net 4.0). But for a List page there will be an entry for each row?
You could also build the menu in code behind.
MetaModel.Default.GetActionPath("Manager", PageAction.List, null);
The above code returns the action path the table "Manager" and the List page.
Aug 02, 2010 12:20 PM|jjfrick|LINK
Thanks Steve, This sounds promising, I'll take a stab at it.
Aug 25, 2010 03:12 PM|jjfrick|LINK
Hi Steve, I have the menu working and I like it and will continue using it but it's not what I have in mind for my "Quik Links" left navigation menu.
It seems to me that it ought to be possible to build a control that could take any list or details page that gets an ID passed to it - to use that ID to create a link to every table where the same ID is a Foreign Key. Example: Say you have just clicked on
the Details link of a record from a list and your url looks like:
http://localhost:123/Employees/Details.aspx?EmployeeID=874 (sample url) Is it possible to create a control that uses EmployeeID to create links to all tables where EmployeeID is a Foreign Key. These links on the side would create a very easy way to bounce
around from table to table, while remaining on Employee 874. I also want to show the employees photo above or below these links. Any ideas are appreciated. Thanks, Jeff
Aug 25, 2010 04:16 PM|sjnaughton|LINK
Hi Jjfrick, I think that is eminantly possible and will have a look at it when I get some time, I'm away fro a week so I wont have a chance until september now [:(]
Dynamic Data 4
Aug 26, 2010 08:29 AM|jjfrick|LINK
Sounds Great. Hope you're going to enjoy your time away. Thanks, Jeff
Aug 26, 2010 09:14 AM|sjnaughton|LINK
I will Jeff [:)]
Sep 08, 2010 04:28 PM|jjfrick|LINK
I wanted to post this just to prevent you from spending valuable time on it. I have a "Quick Links" menu working. I even display an image of the employee. My co-worker helped me get it working. I thought I would include the code in case someone has a need
for the same thing.
I created a EmployeeID.ascx field template:
<%@ Control Language="C#" CodeBehind="EmployeeID.ascx.cs" Inherits="ArchivesDB.EmployeeIDField" %>
<asp:Literal runat="server" ID="Literal1" Text="<%# FieldValueString %>" />
<asp:Panel ID="Panel1" runat="server" CssClass="leftNavContent">
<div class="leftNavImg"><asp:Image ID="Image1" ImageUrl="<%# GetImageUrl() %>" AlternateText="Test" runat="server" /></div>
<asp:Label runat="server"></asp:Label><br />
<asp:Label runat="server">Quick Links</asp:Label><br />
<asp:DynamicHyperLink ID="DynamicHyperLink1" runat="server" NavigateUrl="<%# BioLink() %>" >Biography</asp:DynamicHyperLink><br />
<asp:DynamicHyperLink ID="DynamicHyperLink2" runat="server" NavigateUrl="<%# ResLink() %>" >Residence</asp:DynamicHyperLink><br />
<asp:DynamicHyperLink ID="DynamicHyperLink3" runat="server" NavigateUrl="<%# ResHisLink() %>" >Res History</asp:DynamicHyperLink><br />
<asp:DynamicHyperLink ID="DynamicHyperLink6" runat="server" NavigateUrl="<%# ParLink() %>" >Parental</asp:DynamicHyperLink><br />
<asp:DynamicHyperLink ID="DynamicHyperLink7" runat="server" NavigateUrl="<%# EduLink() %>" >Education</asp:DynamicHyperLink><br />
<asp:DynamicHyperLink ID="DynamicHyperLink8" runat="server" NavigateUrl="<%# PassLink() %>" >Passport</asp:DynamicHyperLink><br />
<asp:DynamicHyperLink ID="DynamicHyperLink9" runat="server" NavigateUrl="<%# EmerLink() %>" >Emergency</asp:DynamicHyperLink><br />
Here's the code behind:
public partial class EmployeeIDField : System.Web.DynamicData.FieldTemplateUserControl
private const int MAX_DISPLAYLENGTH_IN_LIST = 25;
protected override void OnInit(EventArgs e)
if (Request.QueryString["EmployeeID"] == null || Request.QueryString["EmployeeID"] == "")
Visible = false;
Visible = true;
public override string FieldValueString
string value = base.FieldValueString;
if (ContainerType == ContainerType.List)
if (value != null && value.Length > MAX_DISPLAYLENGTH_IN_LIST)
value = value.Substring(0, MAX_DISPLAYLENGTH_IN_LIST - 3) + "...";
protected string GetDisplayString()
public string BioLink()
return "/Biographies/Details.aspx?EmployeeID=" + FieldValue;
public string ResLink()
return "/Residences/Details.aspx?EmployeeID=" + FieldValue;
public string ResHisLink()
return "/ResHistories/List.aspx?EmployeeID=" + FieldValue;
public string ParLink()
return "/Parentals/Details.aspx?EmployeeID=" + FieldValue;
public string EduLink()
return "/Educations/List.aspx?EmployeeID=" + FieldValue;
public string PassLink()
return "/Passport/List.aspx?EmployeeID=" + FieldValue;
public string EmerLink()
return "/Emergencies/List.aspx?EmployeeID=" + FieldValue;
protected string GetImageUrl()
return "http://www.yourwebsite.org/Members/EmployeeDirectoryPhotos/_t/" + FieldValue + "0_jpg.jpg";
public override Control DataControl
You may have noticed a blank asp:Label, I'm trying to find a way to dynamically display the employees name below their picture.