Member_2_1242703
asked on
ASP.NET(VB) accessing controls in a GridView Row
I'm trying to access controls inside a Gridview. It does not like this line:
Dim repeater As Repeater = GridView1.SelectedRow.Find Control("R epeater1")
I suppose because it's not a selected row. What should it be? Here's the entire code...
How do I access the controls inside the GridView Row?
Dim repeater As Repeater = GridView1.SelectedRow.Find
I suppose because it's not a selected row. What should it be? Here's the entire code...
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
For Each GridViewRow In GridView1.Rows
Dim repeater As Repeater = GridView1.SelectedRow.FindControl("Repeater1")
For Each item In repeater.Items
Dim separator As TextBox = item.findcontrol("tbSeparator")
Dim sepList As ListBox = item.findcontrol("lbSeparator")
If sepList.Items.Contains(item.separator.Text) Then
'do something
Else
End If
Next
Next
End Sub
How do I access the controls inside the GridView Row?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
its because you are trying to access item value of a list box,
first try to find the control within the foreach loop and if the control is of type listbox typecast the same in a listbox object.
you must find the control inside of repeater and cast the control to listbox again, to get the selected value you need to again loop through the items of listview. or something like this approach could do the trick.
hope this helps.
first try to find the control within the foreach loop and if the control is of type listbox typecast the same in a listbox object.
you must find the control inside of repeater and cast the control to listbox again, to get the selected value you need to again loop through the items of listview. or something like this approach could do the trick.
hope this helps.
ASKER
Open in new window
Returning: Value of type 'String' cannot be converted to 'System.Web.UI.WebControls