我有一个下拉列表(SingleSelection),它从sql数据库中检索数据,我想将其更改为MultiSelection(选择多值),下面是我的代码。
<asp:DropDownList ID="DrpGroup" runat="server" Width="250px" AutoPostBack="True">
</asp:DropDownList>
Protected Sub DrpGroup_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DrpGroup.SelectedIndexChanged
If (DrpGroup.SelectedValue.ToString.Trim.ToUpper <> "PLEASE SELECT...") Then
Dim cnt_value As Integer = TDES.FindKey("Select Count(*) from dbo.VU_CUSTOMERBYGROUP WHERE upper(ltrim(rtrim(GROUP_NAME)))='" & DrpGroup.SelectedValue.ToString.Trim.ToUpper & "'")
lblNumberCount.Visible = True
lblNumberCount.Text = DrpGroup.SelectedValue.ToString.Trim.ToUpper & " has " & CStr(cnt_value) & " member(s). <br /> The cost for this SMS broadcast will be xxx" & CStr(cnt_value * 0.5)
End If
If (DrpGroup.SelectedValue.ToString.Trim.ToUpper = "PLEASE SELECT...") Then
lblNumberCount.Visible = False
End If
End Sub
您的努力将不胜感激。
答案 0 :(得分:1)
使用ListBox
代替DropDownList
<asp:ListBox runat="server" ID="multiSelect" SelectionMode="multiple" >
<asp:ListItem Text="option1" Value="option1"></asp:ListItem>
<asp:ListItem Text="option2" Value="option2"></asp:ListItem>
<asp:ListItem Text="option3" Value="option3"></asp:ListItem>
</asp:ListBox>