ListView.selectedIndex始终在vb.net中返回值-1 [英] ListView.selectedIndex always returns value -1 in vb.net
本文介绍了ListView.selectedIndex始终在vb.net中返回值-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么ListView.selectedIndex总是在vb.net Framework 3.5中返回值-1?
我曾在C#.Net中尝试过同样的事情,但工作正常...
代码是:
why ListView.selectedIndex always returns value -1 in vb.net framework 3.5 ?
I have tried the same thing in C#.Net is working fine...
Code is:
<asp:ListView ID="lvSectors" runat="server" DataKeyNames="SectorID" OnItemCommand="lvSelectors_ItemCommand"
OnSelectedIndexChanged="lvSelectors_SelectedIndexChanged" OnSelectedIndexChanging="lvSelectors_SelectedIndexChanging">
<table id="itemPlaceholderContainer" runat="server" align="center" border="1" cellpadding="0"
cellspacing="0">
<tr runat="server" style="">
<th align="center">
<asp:LinkButton ID="lbSr_No" runat="server" CommandName="Sort" Width="150"><span style="color :Blue ">Sr No</span>
</th>
<th align="center">
<asp:LinkButton ID="lbSector_Text" runat="server" CommandName="Sort" Width="150"><span style="color :Blue ">SectorName</span>
</th>
<th align="center">
<asp:LinkButton ID="lbDescription" runat="server" CommandName="Sort" Width="150"><span style="color :Blue ">Description</span>
</th>
<th>
Edit
</th>
<th>
Delete
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
<asp:DataPager ID="dpSectors" runat="server" PagedControlID="lvSectors">
<tr>
<td align="center">
<%#Container.DataItemIndex+1 %>
</td>
<td align="center">
<asp:Label ID="lblSector_Text" runat="server" Text='<%#Bind("SectorText") %>'>
</td>
<td align="center">
<asp:Label ID="lblDescription" runat="server" Text='<%#Bind("Description") %>'>
</td>
<td align="center" id="edit1">
<asp:LinkButton ID="lbSector_Edit" runat="server" Width="150" CommandArgument='<%#Bind("SectorID") %>'
CommandName="Select" Text="Edit" CssClass="editclass">
</td>
<td align="center">
<asp:LinkButton ID="lbSector_Delete" runat="server" CommandArgument='<%#Bind("SectorID") %>'
CommandName="Remove" Width="150" Text="Delete" CssClass="deleteClass" OnClientClick='return confirm("Are you sure you want to delete this entry?");'>
</td>
</t
推荐答案
SelectedIndex属性有点混乱.我什至可以称其为框架中的错误.阅读此 [
The SelectedIndex property is more than a bit messed up. I would even go so far as to call it a bug in the framework. Read this[^].
这篇关于ListView.selectedIndex始终在vb.net中返回值-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文