简体   繁体   中英

How is the Dynamic Data Delete Command handled?

I am trying to add another linkbutton into both the PageTemplates/Details.aspx and PageTemplates/List.aspx which mimics the delete command but essentially does a "soft delete", this will use the Command of Remove.

The only problem I have is that I can't see where the current delete command is being handled? I presume the Details.aspx and List.aspx Delete Command goes to the same place so ideally I would like the Remove command to do the same thing so it saves me writing the same code in both places.

This is what the current Gridview looks like on the List.aspx for example

<asp:GridView ID="GridView1" OnDataBound="GridView1_DataBound" runat="server" DataSourceID="GridDataSource" EnablePersistedSelection="true"
            AllowPaging="True" AllowSorting="True" CssClass="DDGridView"
            RowStyle-CssClass="td" HeaderStyle-CssClass="th" CellPadding="6">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:DynamicHyperLink runat="server" Action="Edit" Text="Edit"
                        />&nbsp;<asp:LinkButton runat="server" CommandName="Delete" Text="Delete"
                            OnClientClick='return confirm("Are you sure you want to delete this item?");'
                        />&nbsp;<asp:LinkButton runat="server" Visible="false" CommandName="Remove" Text="Remove"
                            OnClientClick='return confirm("Are you sure you want to remove this item?");'
                        />&nbsp;<asp:DynamicHyperLink runat="server" Text="Details" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>

            <PagerStyle CssClass="DDFooter"/>        
            <PagerTemplate>
                <asp:GridViewPager runat="server" />
            </PagerTemplate>
            <EmptyDataTemplate>
                There are currently no items in this table.
            </EmptyDataTemplate>
</asp:GridView>

As you can see there is no handler on the Delete linkbutton so any help with this would be appreciated. The GridView1_DataBound is my event that just shows or hides the Remove button based on custom attributes.

Standard Insert , Edit and Delete commands don't have explicit handler. They are handled directly by GridView which executes equivalent operation on data source.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM