Option Strict On disallows late binding

  • Thread starter Chris Davey via .NET 247
  • Start date
C

Chris Davey via .NET 247

I always get the late binding error with the following method. Is there anyway around this without turning Option Strict Off?

Private Sub grdAccounts_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdAccounts.ItemDataBound
If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim myBool As Boolean
myBool = DirectCast(e.Item.DataItem("inactive"), Boolean)
If myBool = True Then
For x As Integer = 1 To e.Item.Cells.Count - 1
e.Item.Cells(x).BackColor = System.Drawing.Color.FromName("#ececec")
Next
End If
End If
End Sub
 
B

Brock Allen

You'll have to fix the type mismatch compiler errors and fix them. Strict
Off tells VB.NET to figure it out at runtime (if possible).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top