我有一个列有国家/地区的列表框。用户可以在列表框中选择多个国家/地区。
<asp:ListBox ID="lstRegion" style="width: 115px;size:3px" runat="server"
onselectedindexchanged="lstRegion_SelectedIndexChanged" SelectionMode="Multiple" >
<asp:ListItem Text="Please Select" Value="" Selected="True"></asp:ListItem>
</asp:ListBox>
我需要列表框中的所有选定值。我正在使用lstRegion.selectedValue
,但它只给了我一个值。
我尝试了不同的灵魂,对lstRegion中的项目计数运行循环,并查找是否已选择特定项目。但是这个解决方案看起来并不适合我。
任何人都可以建议我如何在列表框中获取所有选定值
答案 0 :(得分:2)
List<int>mySelectedIndices = new List<int>(lstRegion.GetSelectedIndices());