私はPageTemplates/Details.aspxとPageTemplates/List.aspxの両方にdeleteコマンドを模倣しますが、本質的に「ソフト削除」を行う別のlinkbuttonを追加しようとしています。これはRemoveコマンドを使用します。ダイナミックデータ削除コマンドはどのように処理されますか?
唯一の問題は、現在の削除コマンドがどこで処理されているのかわかりません。私はDetails.aspxとList.aspx Deleteコマンドが同じ場所に移動すると推測します。理想的には、Removeコマンドで同じことをしたいので、両方の場所で同じコードを書くことができます。
これはこれで任意の助けをいただければ幸いですので、削除するLinkButtonにはハンドラがない見ることができるように、現在のGridViewのは、たとえば
<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"
/> <asp:LinkButton runat="server" CommandName="Delete" Text="Delete"
OnClientClick='return confirm("Are you sure you want to delete this item?");'
/> <asp:LinkButton runat="server" Visible="false" CommandName="Remove" Text="Remove"
OnClientClick='return confirm("Are you sure you want to remove this item?");'
/> <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>
ためList.aspxのように見えるものです。 GridView1_DataBoundは、カスタム属性に基づいて[削除]ボタンを表示または非表示にするイベントです。