【发布时间】:2018-10-14 16:30:27
【问题描述】:
我有一个从 sql 数据库中检索数据的下拉列表(SingleSelection),我想将其更改为 MultiSelection(选择多值),以下是我的代码。
ASP.NET
<asp:DropDownList ID="DrpGroup" runat="server" Width="250px" AutoPostBack="True">
</asp:DropDownList>
VB
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
您的努力将不胜感激。
【问题讨论】:
-
asp:DropDownList将不直接支持多选。取而代之的是,您可以使用CheckBoxList或ListBox控件。