Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# AJAX.NET订阅Reorderlist ItemCommand还是DeleteCommand?_C#_Asp.net_Events_Ajax.net_Reorderlist - Fatal编程技术网

C# AJAX.NET订阅Reorderlist ItemCommand还是DeleteCommand?

C# AJAX.NET订阅Reorderlist ItemCommand还是DeleteCommand?,c#,asp.net,events,ajax.net,reorderlist,C#,Asp.net,Events,Ajax.net,Reorderlist,我想订阅页面上的Reorderlist的ItemCommand事件。前端看起来像这样 <cc1:ReorderList id="ReorderList1" runat="server" CssClass="Sortables" Width="400" OnItemReorder="ReorderList1_ItemReorder" OnItemCommand="ReorderList1_ItemCommand"> ... <asp:ImageButton ID="btnDel

我想订阅页面上的Reorderlist的ItemCommand事件。前端看起来像这样

<cc1:ReorderList id="ReorderList1" runat="server" CssClass="Sortables" Width="400"  OnItemReorder="ReorderList1_ItemReorder" OnItemCommand="ReorderList1_ItemCommand">
...
<asp:ImageButton ID="btnDelete" runat="server" ImageUrl="delete.jpg" CommandName="delete" CssClass="playClip" />
...
</cc1:ReorderList>

尽管我尽了最大的努力,但我似乎无法让这项活动启动。如何在ReorderList控件中正确订阅此事件?

由于ImageButton的
CommandName=“delete”
您应该连接到DeleteCommand事件,而不是ItemCommand。

因为ImageButton的
CommandName=“delete”
您应该连接到DeleteCommand事件,而不是ItemCommand。

这可以:

<cc2:ReorderList ID="rlEvents" runat="server" AllowReorder="True" CssClass="reorderList"
        DataKeyField="EventId" DataSourceID="odsEvents" PostBackOnReorder="False"
        SortOrderField="EventOrder" OnDeleteCommand="rlEvents_DeleteCommand">
...
<asp:ImageButton ID="btnDeleteEvent" runat="server" CommandName="Delete" CommandArgument='<%# Eval("EventId") %>' ImageUrl="~/images/delete.gif" />
...
</cc2:ReorderList>
这项工作:

<cc2:ReorderList ID="rlEvents" runat="server" AllowReorder="True" CssClass="reorderList"
        DataKeyField="EventId" DataSourceID="odsEvents" PostBackOnReorder="False"
        SortOrderField="EventOrder" OnDeleteCommand="rlEvents_DeleteCommand">
...
<asp:ImageButton ID="btnDeleteEvent" runat="server" CommandName="Delete" CommandArgument='<%# Eval("EventId") %>' ImageUrl="~/images/delete.gif" />
...
</cc2:ReorderList>
<cc2:ReorderList ID="rlEvents" runat="server" AllowReorder="True" CssClass="reorderList"
        DataKeyField="EventId" DataSourceID="odsEvents" PostBackOnReorder="False"
        SortOrderField="EventOrder" OnDeleteCommand="rlEvents_DeleteCommand">
...
<asp:ImageButton ID="btnDeleteEvent" runat="server" CommandName="Delete" CommandArgument='<%# Eval("EventId") %>' ImageUrl="~/images/delete.gif" />
...
</cc2:ReorderList>
protected void rlEvents_DeleteCommand(object sender, AjaxControlToolkit.ReorderListCommandEventArgs e)
{
   // delete the item
   // this will give you the DataKeyField for the current record -> int.Parse(e.CommandArgument.ToString());
   //rebind the ReorderList
}