locked
Custom "Edit" FormView command? RRS feed

  • Question

  • User1696625220 posted

    Hi, 

    I have a custom page that contains data from two separate tables, a GridView (tableA) and a FormView (tableB). I'd like to (if possible) create a Edit command that links to a different table than the default one. My code below links to (tableA), I'd like it to link to (tableB)

    Is this possible?

                   <asp:FormView runat="server" ID="FormView1" DataSourceID="DetailsDataSource" OnItemDeleted="FormView1_ItemDeleted" RenderOuterTable="false">
                        <HeaderTemplate>
                            <table id="detailsTable" class="DDDetailsTable" cellpadding="2">
                        </HeaderTemplate>
    
                        <ItemTemplate>
                            <table id="detailsTable" class="DDGridView" cellpadding="2">
                                <tr>
                                    <td><h2 class="DDSubHeader">Convent Details</h2></td>
                                </tr>
                                <tr>
                                    <td>
                                        <table id="conventDetails" class="DDDetailsTable" cellpadding="2">
                                            <tr class="td"><td><asp:Label ID="Label1" runat="server">Address1</asp:Label></td><td><asp:Label ID="LblAddress1" runat="server" Text='<%# Eval("Convent.Address1") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label2" runat="server">Address2</asp:Label></td><td><asp:Label ID="LblAddress2" runat="server" Text='<%# Eval("Convent.Address2") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label3" runat="server">Address3</asp:Label></td><td><asp:Label ID="LblAddress3" runat="server" Text='<%# Eval("Convent.Address3") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label4" runat="server">Address4</asp:Label></td><td><asp:Label ID="LblAddress4" runat="server" Text='<%# Eval("Convent.Address4") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label5" runat="server">City</asp:Label></td><td><asp:Label ID="LblCity" runat="server" Text='<%# Eval("Convent.City") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label6" runat="server">State</asp:Label></td><td><asp:Label ID="LblState" runat="server" Text='<%# Eval("Convent.State") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label7" runat="server">Country</asp:Label></td><td><asp:Label ID="LblCountry" runat="server" Text='<%# Eval("Convent.Country") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label8" runat="server">Continent</asp:Label></td><td><asp:Label ID="LblContinent" runat="server" Text='<%# Eval("Convent.Continent") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label9" runat="server">Zipcode</asp:Label></td><td><asp:Label ID="LblZipcode" runat="server" Text='<%# Eval("Convent.Zipcode") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label10" runat="server">Phone</asp:Label></td><td><asp:Label ID="LblPhone" runat="server" Text='<%# Eval("Convent.Phone") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label11" runat="server">Fax</asp:Label></td><td><asp:Label ID="LblFax" runat="server" Text='<%# Eval("Convent.Fax") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label12" runat="server">Group</asp:Label></td><td><asp:Label ID="LblGroup" runat="server" Text='<%# Eval("Convent.Group") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label13" runat="server">Area</asp:Label></td><td><asp:Label ID="Area" runat="server" Text='<%# Eval("Convent.Area") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label14" runat="server">PageNumber</asp:Label></td><td><asp:Label ID="LblPageNumber" runat="server" Text='<%# Eval("Convent.PageNumber") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label15" runat="server">Diocese</asp:Label></td><td><asp:Label ID="LblDiocese" runat="server" Text='<%# Eval("Convent.Diocese") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label16" runat="server">DioState</asp:Label></td><td><asp:Label ID="LblDioState" runat="server" Text='<%# Eval("Convent.DioState") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label17" runat="server">DioCountry</asp:Label></td><td><asp:Label ID="LblDioCounrty" runat="server" Text='<%# Eval("Convent.DioCountry") %>'></asp:Label></td></tr>
                                            <tr class="td"><td><asp:Label ID="Label18" runat="server">CopiesPerHouse</asp:Label></td><td><asp:Label ID="LblCopiesPerHouse" runat="server" Text='<%# Eval("Convent.CopiesPerHouse") %>'></asp:Label></td></tr>
                                            <tr class="td">
                                              <td colspan="2">
                                                <asp:DynamicHyperLink ID="DynamicHyperLink3" runat="server" Action="Edit" Text="Edit" />
                                                <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" Text="Delete"
                                                    OnClientClick='return confirm("Are you sure you want to delete this item?");' />
                                              </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    <EmptyDataTemplate>
                        <div class="DDNoItem">No such item.</div>
                    </EmptyDataTemplate>
                    </asp:FormView>
    


     

    Wednesday, October 10, 2012 2:35 PM

Answers

  • User1696625220 posted

    I'd be happy to:

    <asp:HyperLink ID="customEdit" runat="server" NavigateUrl='<%# "~/Convent/Edit.aspx?ConventID=" + Eval("ConventID") %>'>Edit</asp:HyperLink>

    This page is a custom page -path: /DynamicData/CustomPages/Residence/ConventListDetails.aspx

    From my Global.asax.cs:

                routes.Add(new DynamicDataRoute("{table}/{action}.aspx")
                {
                    Constraints = new RouteValueDictionary(new
                    {
                        action = "ListDetails",
                        table = "Residence"
                    }),
                    ViewName = "ConventListDetails",
                    Model = DefaultModel
                });
    




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 12, 2012 7:58 AM

All replies

  • User1696625220 posted

    I figured it out.

    Wednesday, October 10, 2012 4:00 PM
  • User3866881 posted

    I figured it out.

    Congratulation!

    Would you mind telling me how to deal with that?You can mark yourself as an answer.

    Thursday, October 11, 2012 10:12 PM
  • User1696625220 posted

    I'd be happy to:

    <asp:HyperLink ID="customEdit" runat="server" NavigateUrl='<%# "~/Convent/Edit.aspx?ConventID=" + Eval("ConventID") %>'>Edit</asp:HyperLink>

    This page is a custom page -path: /DynamicData/CustomPages/Residence/ConventListDetails.aspx

    From my Global.asax.cs:

                routes.Add(new DynamicDataRoute("{table}/{action}.aspx")
                {
                    Constraints = new RouteValueDictionary(new
                    {
                        action = "ListDetails",
                        table = "Residence"
                    }),
                    ViewName = "ConventListDetails",
                    Model = DefaultModel
                });
    




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 12, 2012 7:58 AM