Value o type 'Control' cannot be converted to 'Label' in vb.net
I have done extensive searching for how to retrieve the information from a datalist and populate a text box and I have seen basically the same response, and I keep getting the same error.
Here is a sample of code that was previously supplied inside this MSDN forum that apparently worked for someone:
Protected Sub NegotiationsUpdatesDataList_EditCommand(ByVal source As Object, ByVal e As DataListCommandEventArgs) Handles UpdatesDataList.EditCommand
dim lbl as Label = CType(e.Item.FindControl("lblText"), Label)
UpdateText.Text = lbl.Text
End Sub
No matter if I use CType, DirectCast or TryCast I get the same error:
Value o type 'Control' cannot be converted to 'Label'
I am using asp.net with vb code behind and in my code behind I am using:
Imports System.Windows.Forms
Any help with why this seems the only way to do this, and yet I get errors...