我有一个分页的多列ListView与ImageButton和LinkButton的项目。删除和选择命令正在工作。我无法触发SelectedIndexChanging事件,并且SelectIndex在Select命令处理程序中始终为-1。我想我有按照文档所需的选择按钮。我的最终目标是保存项目的索引,因此当我返回页面时,我可以恢复当前的ListView寻呼机页面,以便所选项目可见。但我无法获得物品索引。这是为asp.net 4.0 webforms。ListView选择索引
<asp:ListView ID="ListView1" runat="server" OnItemDataBound="ListView1_ItemDataBound"
DataKeyNames="ItemID" DataSourceID="ObjectDataSource1"
OnItemCommand="ListView1_ItemCommand" GroupItemCount="2"
onselectedindexchanging="ListView1_SelectedIndexChanging">
<LayoutTemplate>
<table width="100%">
<tr>
<td>
<table class="sample" width="100%">
<asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
</table>
</td>
</tr>
</table>
</LayoutTemplate>
<GroupTemplate>
<tr>
<asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<td>
<asp:ImageButton ID="btnDelete" ToolTip="Delete" runat="server" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ItemID")%>' CommandName="DeleteItem" Height="12" ImageUrl="resources/delete.gif" Width="12" />
<asp:LinkButton ID="btnSelect" runat="server" CommandName="Select" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ItemID")%>'><%# DataBinder.Eval(Container.DataItem, "ItemName") %></asp:LinkButton>
<asp:Label ID="ccLabel" runat="server"></asp:Label>
</td>
</ItemTemplate>
</asp:ListView>
我想我会尝试DataPager.StartRowIndex属性,而不是坚持它为用户返回页面。 –