【发布时间】:2016-05-22 18:05:27
【问题描述】:
我想检索列表框中当前选定项目的值,并且每当用户选择更多项目时,这些项目的价格总和将显示在标签中,例如:用户从列表框中选择 2 个电话名称和他们的价格总和将显示在标签 中(它仅适用于用户选择的第一个项目,但忽略其他所有选择,当用户选择一个项目时它不起作用它只在我显示价格时按一个按钮),这是我尝试过的:
Partial Class PickItems
Inherits System.Web.UI.Page
Dim sum As Integer = 0
Protected Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
sum = sum + CInt(ListBox1.SelectedValue)
Label1.Text = sum.ToString()
End Sub
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Label2.Text = Request.QueryString("Name").ToString()
End Sub End Class
这是列表框代码 <asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple" DataSourceID="SqlDataSource1" DataTextField="PhoneName" DataValueField="PhonePrice"></asp:ListBox>
下面是页面的样子: 我还需要将选定的项目从这个页面移动到下一页(就像我对 Request.QueryString("Name... .) 任何帮助将不胜感激!
【问题讨论】: