I want to retrieve the values of the current selected items in the listbox and whenever the user pick more items,the sum of price of these items will be displayed in a Label ex: the user picks 2 phone names from the listbox and the sum of their price will be displayed in the label (It is working for only the first item the user chooses but ignores everything else selected and it doen't work when the user select an item it only displays the price when i press a button) ,Here is what i tried :
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
Here is the Listbox code <asp:ListBox ID="ListBox1" runat="server" SelectionMode="Multiple" DataSourceID="SqlDataSource1" DataTextField="PhoneName" DataValueField="PhonePrice"></asp:ListBox>
And here is how the page looks like:
I will also need to move the selected items from this page to the next page(same as i did with the Request.QueryString("Name....) Any help will be appreciated!