Got a real Bizarre one.
Am populating a list box via linq.
Just have a button that should tell me the listbox id via a text box.
But when I push the button it states that the selectedItem is nothing.
The data is being sent to the listbox. It is almost like the listbox is stating that nothing is selected.
Heres the code:
Populate the Listbox:
----------------------------------------
Dim DC As DataClasses1DataContext
DC = New DataClasses1DataContext
Me.LB_Job.DataSource = From C In DC.SM_CLIENTs, J In DC.SM_JOBs _
Where (J.SM_JOB_ACTIVE = True) And _
C.SM_CLIENT_ID = J.SM_CLIENT_ID
Select J.SM_JOB_ID, C.SM_CLIENT_NAME
Me.LB_Job.DataTextField = "SM_CLIENT_NAME"
Me.LB_Job.DataValueField = "SM_JOB_ID"
Me.LB_Job.DataBind()
--------------------------------
AND NOW THE BUTTON:
Protected Sub Btn_Start_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Btn_Start.Click
Me.TxtBoxOperator.Text = Me.LB_Job.SelectedItem.Text
End Sub
Any ideas? I'm stumped
Am populating a list box via linq.
Just have a button that should tell me the listbox id via a text box.
But when I push the button it states that the selectedItem is nothing.
The data is being sent to the listbox. It is almost like the listbox is stating that nothing is selected.
Heres the code:
Populate the Listbox:
----------------------------------------
Dim DC As DataClasses1DataContext
DC = New DataClasses1DataContext
Me.LB_Job.DataSource = From C In DC.SM_CLIENTs, J In DC.SM_JOBs _
Where (J.SM_JOB_ACTIVE = True) And _
C.SM_CLIENT_ID = J.SM_CLIENT_ID
Select J.SM_JOB_ID, C.SM_CLIENT_NAME
Me.LB_Job.DataTextField = "SM_CLIENT_NAME"
Me.LB_Job.DataValueField = "SM_JOB_ID"
Me.LB_Job.DataBind()
--------------------------------
AND NOW THE BUTTON:
Protected Sub Btn_Start_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Btn_Start.Click
Me.TxtBoxOperator.Text = Me.LB_Job.SelectedItem.Text
End Sub
Any ideas? I'm stumped