Click here to Skip to main content
15,918,243 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am running a program where i am selecting stations from the combobox 'stn_list_'
but when ever I run the code and i select different stations from the combobox.....i got the static value i.e '2ad'
plz help......

VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       con.Open()
       stn_list.Items.Clear()


       Dim cmd4 As New SqlCommand("Select distinct stn from zonemaster", con)
       Dim dr4 As SqlDataReader = cmd4.ExecuteReader
       While (dr4.Read)
           stn_list.Items.Add(IIf(IsDBNull(dr4("stn")), "Null", dr4("stn")))
       End While
       con.Close()
   End Sub

   Protected Sub stn_list_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles stn_list.SelectedIndexChanged
       con.Open()
       party_list.Items.Clear()
       Dim stn As String
       stn = ""

       stn = stn_list.Text


       Dim cmd5 As New SqlCommand("Select  consignor from partymst where left(datatr,3)='" & stn & "'", con)
       Dim dr5 As SqlDataReader = cmd5.ExecuteReader
       While (dr5.Read)
           party_list.Items.Add(IIf(IsDBNull(dr5("consignor")), "Null", dr5("consignor")))
       End While
       con.Close()
   End Sub
Posted
Updated 16-Apr-12 19:40pm
v2
Comments
Sergey Alexandrovich Kryukov 17-Apr-12 0:39am    
Is it ASP.NET? Something else? Please tag it.
--SA

1 solution

You just change the code from stn_list.text to stn_list.selectedValue on the form any selected value true of combobox to change with the selected = false.


VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       con.Open()
       stn_list.Items.Clear()


       Dim cmd4 As New SqlCommand("Select distinct stn from zonemaster", con)
       Dim dr4 As SqlDataReader = cmd4.ExecuteReader
       While (dr4.Read)
           stn_list.Items.Add(IIf(IsDBNull(dr4("stn")), "Null", dr4("stn")))
       End While
       con.Close()
   End Sub

   Protected Sub stn_list_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles stn_list.SelectedIndexChanged
       con.Open()
       party_list.Items.Clear()
       Dim stn As String
       stn = ""

       stn = stn_list.SelectedValue;


       Dim cmd5 As New SqlCommand("Select  consignor from partymst where left(datatr,3)='" & stn & "'", con)
       Dim dr5 As SqlDataReader = cmd5.ExecuteReader
       While (dr5.Read)
           party_list.Items.Add(IIf(IsDBNull(dr5("consignor")), "Null", dr5("consignor")))
       End While
       con.Close()
   End Sub
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900