I really need help with this one. I don't know why this is happening...
I have a single selection listbox in an itemtemplate within a datagrid. All I want to do is check to see if an item has been selected form the listbox (see code below)
<code>
If lstSelectionCrewChief.SelectedIndex > -1 Then
drCrewChief = DsCrewChief1.CrewChiefs.FindByUserID(lstSelectionCrewChief.SelectedValue)
lngCrewChiefUserID = drCrewChief.UserID
Else
lngCrewChiefUserID = -1
End If
</code>
The thing is, that the listbox has a SelectedIndex = 0 (meaning the first item is selected). I don't have it highlighted at all on my aspx page. It seems that the first item is a default for the SelectedItem in the listbox. If that's the case, how can I check if an item in the listbox has been selected or not?
I tried the following code, iterating thru the lisbox and still came up with the first item selected causing it to go inside the "IF" statement.
<code>
For Each li In lstSelectionCrewChief.Items
If li.Selected = True Then
.
.
.
End If
Next
</code>
How do these templated listboxes work in regards to this?
I tried a separate listbox control on an aspx page (not within a template inside a datagrid), and this works fine....... Why not the template inside the datagrid???


Reply With Quote