My DataList ItemTemplate:
--------------------
UserId:[UserIdLabel]
Add
--------------------
If I click on add the method (code behind) fires.
The only thing I need is to get the UserId to use
it in my function.
Protected Sub LinkButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
TextBox1.Text = DirectCast(DataListSearchResults.Items(DataListSearchResults.SelectedIndex).FindControl("UserId"), Label).Text
End Sub
But my approach of direct casting and finding the control has an error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Do you guys have a suggestion how to fix this ?
Many thanks,
Polynaux
--------------------
UserId:[UserIdLabel]
Add
--------------------
If I click on add the method (code behind) fires.
The only thing I need is to get the UserId to use
it in my function.
Protected Sub LinkButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
TextBox1.Text = DirectCast(DataListSearchResults.Items(DataListSearchResults.SelectedIndex).FindControl("UserId"), Label).Text
End Sub
But my approach of direct casting and finding the control has an error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Do you guys have a suggestion how to fix this ?
Many thanks,
Polynaux