tshad said:
My mistake. I thought I did.
I am getting:
Error 54 Option Strict On disallows late binding.
I get this for:
parameters(0).Value = Session("User").CompanyID
Where User is a class.
And I also get it for:
Sub SetMoveList_Click(ByVal s As Object, ByVal e As EventArgs)
Trace.Warn("in SetMove_Click s.id = " & s.id)
Dim oPanel As Panel = s.parent
Dim oDLI As DataListItem = s.parent.parent
Here I am trying to get the Panel and DataListItem which works fine if
Option Strict is Off.
Why would this be a problem with it on. "s" is an object and objects
have parents.
Thanks,
Tom
First off objects do not have parents. What you need to do is use CType to
tell the compiler what the objects are. For example s is not an object,
it is a class that is derived from object.
What?
It is defined as an object:
ByVal s As Object
So whatever SetMoveList is , is the object type in the CType statement.
I thought objects had parents. Maybe that was because I used to write my
code with Option Strict Off (actually defaulted to that) and I would use
s.Parent all the time.
If objects don't have parents, do I need to change:
s.Parent,Parent,Parent to something like:
CType(CType(Ctype(CType(s,something).Parent,something).Parent,something).Parent,something)
Because in each case we would need to know what the parent is.
Also, why does this work:
I don't this is the case as this works:
Dim theParent As Control = CType(sender,DataGridItem).Parent.Parent
I don't need to cast each parent.
But I do need to cast this:
Dim oDataList As DataListItem = CType(CType(s, ImageButton).Parent.Parent,
DataListItem)
Doesn't seem too consistant
Something like:
dim oPanel as Panel = ctype(s,HtmlButton).parent
But would you not nee to Ctype the whole thing as Panel?