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 Integer02. ' 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 control04. 'AddEvent("IndexOfKeyOrValue Looking For: " & myString & " in " & ddl.Name)05. Try06. For xx As Integer = 0 To ddl.Items.Count07. 'AddEvent(ddl.DataSource(xx).Key & " " & ddl.DataSource(xx).Value)08. If LocateKey Then09. If ddl.DataSource(xx).Key = myString Then10. 'AddEvent("---- Index Found = " & xx)11. Return xx12. End If13. Else14. If ddl.DataSource(xx).Value = myString Then15. 'AddEvent("---- Index Found = " & xx)16. Return xx17. End If18. End If19. 20. Next21. Catch ex As Exception22. ' AddEvent("---- NOT FOUND Index = -1")23. Return -124. End Try25.End Function 'IndexOfKeyOrValue