HighTechTalks DotNet Forums  

Option Strict On disallows late binding

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss Option Strict On disallows late binding in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Chris Davey via .NET 247
 
Posts: n/a

Default Option Strict On disallows late binding - 04-06-2005 , 10:50 AM






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>

Reply With Quote
  #2  
Old   
Brock Allen
 
Posts: n/a

Default Re: Option Strict On disallows late binding - 04-06-2005 , 12:29 PM






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



Quote:
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





Reply With Quote
  #3  
Old   
brench
 
Posts: n/a

Default Re: Option Strict On disallows late binding - 09-19-2005 , 04:25 PM




Chris,

I don't know if you got an answer to this, but I was facing the sam
issue and did this:

DataBinder.Eval(e.Item.DataItem, "nameOfYourDataItem").ToString


I converted to a string, but you can convert (CType) to whatever yo
want.



Bra

--
brenc



Reply With Quote
  #4  
Old   
Jasee DelaCombo
 
Posts: n/a

Default Re: Option Strict On disallows late binding - 11-20-2007 , 07:15 PM



Using DataBinder.Eval* Worked for me. I was hitting my head on the table
trying to figure this out. I converted a Visual Studio 2003 web app to
Visual Studio 2005 and am going through tons of needed conversions to comply.


Thanks!

url:http://www.ureader.com/msg/1422137.aspx

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.