G
Guest
To all,
I have a listbox within a gridview that exists in an update panel. When I
try to get the values of each selected item in my listbox I get nothing.
When I'm in debug mode I get false for each item that I selected from my
listbox. I also get length=0 as a value for each item that I selected when I
use getselectedindices().
I have validated that I'm on the right row that has my listbox and I put my
gridview out of the update panel to see if there is a client side issue.
However, I'm still not able to get the selected values from the selected
items/index chosen from my list box. Can anyone help?
Here is my VB code behind:
Protected Sub btnSelectComputer_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim ChosenItems As String = Nothing
For Each gvrow As GridViewRow In gvADComputer.Rows
Dim lb As ListBox = CType(gvrow.FindControl("lbItems"), ListBox)
'Dim selections() As Integer = lb.GetSelectedIndices()
'Dim lb As ListBox = CType(FindControlRecursive(gvrow,
"lbItems"), ListBox)
For Each selectedItem As ListItem In lb.Items
If selectedItem.Selected Then 'Len(selectedItem.Value) > 0
Then
ChosenItems += selectedItem.Value + ", "
End If
Next
Next
tbTest1.Text = ChosenItems
End Sub
I have a listbox within a gridview that exists in an update panel. When I
try to get the values of each selected item in my listbox I get nothing.
When I'm in debug mode I get false for each item that I selected from my
listbox. I also get length=0 as a value for each item that I selected when I
use getselectedindices().
I have validated that I'm on the right row that has my listbox and I put my
gridview out of the update panel to see if there is a client side issue.
However, I'm still not able to get the selected values from the selected
items/index chosen from my list box. Can anyone help?
Here is my VB code behind:
Protected Sub btnSelectComputer_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim ChosenItems As String = Nothing
For Each gvrow As GridViewRow In gvADComputer.Rows
Dim lb As ListBox = CType(gvrow.FindControl("lbItems"), ListBox)
'Dim selections() As Integer = lb.GetSelectedIndices()
'Dim lb As ListBox = CType(FindControlRecursive(gvrow,
"lbItems"), ListBox)
For Each selectedItem As ListItem In lb.Items
If selectedItem.Selected Then 'Len(selectedItem.Value) > 0
Then
ChosenItems += selectedItem.Value + ", "
End If
Next
Next
tbTest1.Text = ChosenItems
End Sub