我想删除我的 asp.net ListView 中的一个条目,但它不适用于我的代码。
我的代码:
protected void ListView_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
int index = Convert.ToInt32(e.CommandArgument);
int listcount = ListView.Items.Count;
if (listcount - 1 == index)
{
ListView.Items.RemoveAt(index); //go do ListView_Deleting
}
}
}
protected void ListView_SelectedIndexChanging(object sender, EventArgs e)
{
//
}
protected void ListView_Deleting(object sender, EventArgs e)
{
//
}
我的aspx:
<div class="InputControlBox">
<asp:ListView ID="ListView" runat="server" OnItemCommand="ListView_ItemCommand"
OnSelectedIndexChanging="ListView_SelectedIndexChanging" OnItemDeleting="ListView_Deleting">
<LayoutTemplate>
...
</LayoutTemplate>
<ItemTemplate>
...
</ItemTemplate>
</asp:ListView>
</div>
错误在哪里?