Method to Create 2 Views of 1 Table?

Last post 05-10-2008 12:47 PM by tlanier. 2 replies.

Sort Posts:

  • Method to Create 2 Views of 1 Table?

    05-10-2008, 11:07 AM
    • Loading...
    • tlanier
    • Joined on 04-29-2008, 9:20 AM
    • Posts 67

    Is there a method to create 2 views of 1 table? Let me try to give an example.

    Say I have a Customers table and I create a custom page with the folder name Customers. This gives me the first view of Customers.

    Now I want to design a 2nd custom Customers page that has a different purpose and view. Is there a way to do this.

    Do the routing routines somehow allow this?

    Thanks,

    Tommy

  • Re: Method to Create 2 Views of 1 Table?

    05-10-2008, 11:39 AM
    Answer
    • Loading...
    • davidebb
    • Joined on 06-11-2002, 8:31 AM
    • Redmond, WA
    • Posts 853
    • AspNetTeam

    Try something like this:

    • When creating links that you want going to the alternate view, call table.GetActionPath("SpecialDetails", GetDataItem())
    • In global.asax, add the new action name to the constraint list of the route, e.g. action = "List|Details|SpecialDetails|Edit|Insert".  Or you can remove the constraints altogether.

    David

  • Re: Method to Create 2 Views of 1 Table?

    05-10-2008, 12:47 PM
    • Loading...
    • tlanier
    • Joined on 04-29-2008, 9:20 AM
    • Posts 67

    David, that works great!

    For others to see:

    In "global.asax":

            // This route uses a different page for each action. To use an all-in-one page instead, please
            // comment out this route and uncomment the following two
    		routes.Add(new DynamicDataRoute("{table}/{action}.aspx")
    		{
    			Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert|View2" }),
    			Model = model
    		});
    


    In a custom page folder in the list file "List.aspx":

     
            
                
                    
       					"View2Link" runat="server"
                            NavigateUrl='<%# table.GetActionPath("View2", GetDataItem()) %>'
                            Text="View2"> 
    
                        "EditHyperLink" runat="server"
                            NavigateUrl='<%# table.GetActionPath(PageAction.Edit, GetDataItem()) %>'
    						Text="Edit"> 
                        
                        "DeleteLinkButton" runat="server" CommandName="Delete"
                            CausesValidation="false" Text="Delete"
                            OnClientClick='return confirm("Are you sure you want to delete this item?");'
                       > 
                        
                        "DetailsHyperLink" runat="server"
                            NavigateUrl='<%# table.GetActionPath(PageAction.Details, GetDataItem()) %>'
                            Text="Details">
                    
    

    Thanks,

    Tommy
    Sorry for the poor formatting of the code. I keep struggling to figure out how to get a well formatted message displayed on this site. 
    Even when I use the "Source Code" option the white space is always out of whack.
     
Page 1 of 1 (3 items)