2010-06-02 113 views
0

我有一個列表框,裏面裝滿了國家。用戶可以在列表框中選擇多個國家。需要幫助的列表框多選

<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中的項目數,並查找是否已選擇特定項目。但是這個解決方案對我來說並不好看。

任何一個可以建議我如何讓所有selectedvalues在列表框中

回答

2
List<int>mySelectedIndices = new List<int>(lstRegion.GetSelectedIndices());