We are in the early process of converting from VB to C#. Before we convert, we are turning on Option Strict, one project at a time. I got the following Late Binding error on a RadDropDownList.DataSource. DataSource is deemed as an object (line 09 & 14), which is what is throwing the error, but not sure how to repair this. (error screenshot attached)
01.
Public
Shared
Function
IndexOfKeyOrValue(
ByRef
ddl
As
RadDropDownList,
ByVal
myString
As
String
,
ByVal
LocateKey
As
Boolean
)
As
Integer
02.
' What I would like to do is pass any control to this function, see if it has a datasource and then do the rest.
03.
' Use the TypeOf to determine the type of the control
04.
'AddEvent("IndexOfKeyOrValue Looking For: " & myString & " in " & ddl.Name)
05.
Try
06.
For
xx
As
Integer
= 0
To
ddl.Items.Count
07.
'AddEvent(ddl.DataSource(xx).Key & " " & ddl.DataSource(xx).Value)
08.
If
LocateKey
Then
09.
If
ddl.DataSource(xx).Key = myString
Then
10.
'AddEvent("---- Index Found = " & xx)
11.
Return
xx
12.
End
If
13.
Else
14.
If
ddl.DataSource(xx).Value = myString
Then
15.
'AddEvent("---- Index Found = " & xx)
16.
Return
xx
17.
End
If
18.
End
If
19.
20.
Next
21.
Catch
ex
As
Exception
22.
' AddEvent("---- NOT FOUND Index = -1")
23.
Return
-1
24.
End
Try
25.
End
Function
'IndexOfKeyOrValue