Option Strict On disallows late binding

Discussion in 'ASP .Net Datagrid Control' started by Chris Davey via .NET 247, Apr 6, 2005.

  1. 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

    --------------------------------
    From: Chris Davey

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>jOwUfUmTwE+j80N6FGjw5w==</Id>
    Chris Davey via .NET 247, Apr 6, 2005
    #1
    1. Advertising

  2. Chris Davey via .NET 247

    Brock Allen Guest

    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).

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > 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
    > --------------------------------
    > From: Chris Davey
    > -----------------------
    > Posted by a user from .NET 247 (http://www.dotnet247.com/)
    > <Id>jOwUfUmTwE+j80N6FGjw5w==</Id>
    >
    Brock Allen, Apr 6, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karl Lang
    Replies:
    1
    Views:
    887
    Karl Lang
    Jun 1, 2004
  2. Ryan McLean

    Option Strict On disallows late binding.

    Ryan McLean, Jun 14, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    10,323
    mikeb
    Jun 14, 2004
  3. Owen Mortensen
    Replies:
    7
    Views:
    3,129
    Owen Mortensen
    Mar 13, 2006
  4. Adotek
    Replies:
    1
    Views:
    428
    Bruno Alexandre
    Oct 3, 2006
  5. Seema
    Replies:
    1
    Views:
    842
    Arne Vajhøj
    Jan 25, 2012
Loading...

Share This Page