Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid: Option Strict On disallows late binding -- HELP

Reply
Thread Tools

Datagrid: Option Strict On disallows late binding -- HELP

 
 
Owen Mortensen
Guest
Posts: n/a
 
      03-10-2006
(This code was working in asp.net 1.1 VS2003. After upgrade to VS2005,
chokes):

in the aspx file:

<ItemTemplate>
<asp:datagrid id="dg_instr" runat="server" AutoGenerateColumns="False"
HeaderStyle-Font-Bold="True"
CellPadding="0" CellSpacing="1" Font-Size="Small" BackColor="Transparent"
ForeColor="Black"
BorderStyle="None" BorderColor="#CCCCFF"
DataSource=<%# buildInstrumentListDataGrid(container.dataitem("Ca tID"))%>>

I get the error: Option Strict On disallows late binding

What item is being late-bound? And how do I not late-bind it?

Here's the function:

Function buildInstrumentListDataGrid(ByVal CatID As String) As DataTable
Dim lp_survey_Connect As New dBUtils("sConnectLPSurvey")
Dim strInstrSQLQuery As String
Dim objInstrDataSet As New DataSet

strInstrSQLQuery = "SELECT InstID, InstName, CatID" & _
" FROM InstrumentList" & _
" WHERE CatID = " & CatID & " ORDER BY InstID"

objInstrDataSet = lp_survey_Connect.GetDataSet(strInstrSQLQuery, False)
lp_survey_Connect.Dispose()

Return objInstrDataSet.Tables(0)

End Function

Thanks,








--------------------------------------------------------------------------------
Owen


 
Reply With Quote
 
 
 
 
Marina Levit [MVP]
Guest
Posts: n/a
 
      03-10-2006
container.dataitem("CatID") does not return a string - it returns an object.
You are not explicitly casting it to a string, so that is your problem.

"Owen Mortensen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> (This code was working in asp.net 1.1 VS2003. After upgrade to VS2005,
> chokes):
>
> in the aspx file:
>
> <ItemTemplate>
> <asp:datagrid id="dg_instr" runat="server" AutoGenerateColumns="False"
> HeaderStyle-Font-Bold="True"
> CellPadding="0" CellSpacing="1" Font-Size="Small" BackColor="Transparent"
> ForeColor="Black"
> BorderStyle="None" BorderColor="#CCCCFF"
> DataSource=<%# buildInstrumentListDataGrid(container.dataitem("Ca tID"))%>>
>
> I get the error: Option Strict On disallows late binding
>
> What item is being late-bound? And how do I not late-bind it?
>
> Here's the function:
>
> Function buildInstrumentListDataGrid(ByVal CatID As String) As DataTable
> Dim lp_survey_Connect As New dBUtils("sConnectLPSurvey")
> Dim strInstrSQLQuery As String
> Dim objInstrDataSet As New DataSet
>
> strInstrSQLQuery = "SELECT InstID, InstName, CatID" & _
> " FROM InstrumentList" & _
> " WHERE CatID = " & CatID & " ORDER BY InstID"
>
> objInstrDataSet = lp_survey_Connect.GetDataSet(strInstrSQLQuery, False)
> lp_survey_Connect.Dispose()
>
> Return objInstrDataSet.Tables(0)
>
> End Function
>
> Thanks,
>
>
>
>
>
>
>
>
> --------------------------------------------------------------------------------
> Owen
>



 
Reply With Quote
 
 
 
 
Owen Mortensen
Guest
Posts: n/a
 
      03-10-2006
OK. I don't know how to do that?

I don't see "container.dataitem" anywhere....

?

"Marina Levit [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> container.dataitem("CatID") does not return a string - it returns an
> object. You are not explicitly casting it to a string, so that is your
> problem.
>
> "Owen Mortensen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> (This code was working in asp.net 1.1 VS2003. After upgrade to VS2005,
>> chokes):
>>
>> in the aspx file:
>>
>> <ItemTemplate>
>> <asp:datagrid id="dg_instr" runat="server" AutoGenerateColumns="False"
>> HeaderStyle-Font-Bold="True"
>> CellPadding="0" CellSpacing="1" Font-Size="Small" BackColor="Transparent"
>> ForeColor="Black"
>> BorderStyle="None" BorderColor="#CCCCFF"
>> DataSource=<%#
>> buildInstrumentListDataGrid(container.dataitem("Ca tID"))%>>
>>
>> I get the error: Option Strict On disallows late binding
>>
>> What item is being late-bound? And how do I not late-bind it?
>>
>> Here's the function:
>>
>> Function buildInstrumentListDataGrid(ByVal CatID As String) As DataTable
>> Dim lp_survey_Connect As New dBUtils("sConnectLPSurvey")
>> Dim strInstrSQLQuery As String
>> Dim objInstrDataSet As New DataSet
>>
>> strInstrSQLQuery = "SELECT InstID, InstName, CatID" & _
>> " FROM InstrumentList" & _
>> " WHERE CatID = " & CatID & " ORDER BY InstID"
>>
>> objInstrDataSet = lp_survey_Connect.GetDataSet(strInstrSQLQuery, False)
>> lp_survey_Connect.Dispose()
>>
>> Return objInstrDataSet.Tables(0)
>>
>> End Function
>>
>> Thanks,
>>
>>
>>
>>
>>
>>
>>
>>
>> --------------------------------------------------------------------------------
>> Owen
>>

>
>



 
Reply With Quote
 
Owen Mortensen
Guest
Posts: n/a
 
      03-10-2006
So, I changed container.dataitem("CatID") to
container.dataitem("CatID").ToString() ... still get the same error. I do
not know how this construct works: something I copied out of a book.... Is
there an explanation somewhere documented?

Owen

"Marina Levit [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> container.dataitem("CatID") does not return a string - it returns an
> object. You are not explicitly casting it to a string, so that is your
> problem.
>
> "Owen Mortensen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> (This code was working in asp.net 1.1 VS2003. After upgrade to VS2005,
>> chokes):
>>
>> in the aspx file:
>>
>> <ItemTemplate>
>> <asp:datagrid id="dg_instr" runat="server" AutoGenerateColumns="False"
>> HeaderStyle-Font-Bold="True"
>> CellPadding="0" CellSpacing="1" Font-Size="Small" BackColor="Transparent"
>> ForeColor="Black"
>> BorderStyle="None" BorderColor="#CCCCFF"
>> DataSource=<%#
>> buildInstrumentListDataGrid(container.dataitem("Ca tID"))%>>
>>
>> I get the error: Option Strict On disallows late binding
>>
>> What item is being late-bound? And how do I not late-bind it?
>>
>> Here's the function:
>>
>> Function buildInstrumentListDataGrid(ByVal CatID As String) As DataTable
>> Dim lp_survey_Connect As New dBUtils("sConnectLPSurvey")
>> Dim strInstrSQLQuery As String
>> Dim objInstrDataSet As New DataSet
>>
>> strInstrSQLQuery = "SELECT InstID, InstName, CatID" & _
>> " FROM InstrumentList" & _
>> " WHERE CatID = " & CatID & " ORDER BY InstID"
>>
>> objInstrDataSet = lp_survey_Connect.GetDataSet(strInstrSQLQuery, False)
>> lp_survey_Connect.Dispose()
>>
>> Return objInstrDataSet.Tables(0)
>>
>> End Function
>>
>> Thanks,
>>
>>
>>
>>
>>
>>
>>
>>
>> --------------------------------------------------------------------------------
>> Owen
>>

>
>



 
Reply With Quote
 
Marina Levit [MVP]
Guest
Posts: n/a
 
      03-10-2006
Well, this was one spot where I could see this being a problem - you did not
tell us what line number is actually causing the compile time error, or
whether or not you are using code behind.
I am sort of surprised that an upgrade to 2005 would cause this. I have not
encountered any Option Strict differences when upgrading code.

"Owen Mortensen" <(E-Mail Removed)> wrote in message
news:e$(E-Mail Removed)...
> So, I changed container.dataitem("CatID") to
> container.dataitem("CatID").ToString() ... still get the same error. I do
> not know how this construct works: something I copied out of a book.... Is
> there an explanation somewhere documented?
>
> Owen
>
> "Marina Levit [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> container.dataitem("CatID") does not return a string - it returns an
>> object. You are not explicitly casting it to a string, so that is your
>> problem.
>>
>> "Owen Mortensen" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> (This code was working in asp.net 1.1 VS2003. After upgrade to VS2005,
>>> chokes):
>>>
>>> in the aspx file:
>>>
>>> <ItemTemplate>
>>> <asp:datagrid id="dg_instr" runat="server" AutoGenerateColumns="False"
>>> HeaderStyle-Font-Bold="True"
>>> CellPadding="0" CellSpacing="1" Font-Size="Small"
>>> BackColor="Transparent" ForeColor="Black"
>>> BorderStyle="None" BorderColor="#CCCCFF"
>>> DataSource=<%#
>>> buildInstrumentListDataGrid(container.dataitem("Ca tID"))%>>
>>>
>>> I get the error: Option Strict On disallows late binding
>>>
>>> What item is being late-bound? And how do I not late-bind it?
>>>
>>> Here's the function:
>>>
>>> Function buildInstrumentListDataGrid(ByVal CatID As String) As DataTable
>>> Dim lp_survey_Connect As New dBUtils("sConnectLPSurvey")
>>> Dim strInstrSQLQuery As String
>>> Dim objInstrDataSet As New DataSet
>>>
>>> strInstrSQLQuery = "SELECT InstID, InstName, CatID" & _
>>> " FROM InstrumentList" & _
>>> " WHERE CatID = " & CatID & " ORDER BY InstID"
>>>
>>> objInstrDataSet = lp_survey_Connect.GetDataSet(strInstrSQLQuery,
>>> False)
>>> lp_survey_Connect.Dispose()
>>>
>>> Return objInstrDataSet.Tables(0)
>>>
>>> End Function
>>>
>>> Thanks,
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --------------------------------------------------------------------------------
>>> Owen
>>>

>>
>>

>
>



 
Reply With Quote
 
Owen Mortensen
Guest
Posts: n/a
 
      03-10-2006
Sorry. I AM using code-behind. So the control directive looks like this:
<%@ Control Language="vb" AutoEventWireup="false"
CodeFile="lp_survey_display_edit.ascx.vb"
Inherits="cwsBackOffice.lp_survey_display_edit" %>

AND, the top of the code-behind file looks like this:
Imports System.Data
Imports System.Data.SqlClient
Imports Functions

Namespace cwsBackOffice
Partial Class lp_survey_display_edit
Inherits System.Web.UI.UserControl

Any ideas?
Thanks,
Owen

"Marina Levit [MVP]" <(E-Mail Removed)> wrote in message
news:e%(E-Mail Removed)...
> Well, this was one spot where I could see this being a problem - you did
> not tell us what line number is actually causing the compile time error,
> or whether or not you are using code behind.
> I am sort of surprised that an upgrade to 2005 would cause this. I have
> not encountered any Option Strict differences when upgrading code.
>
> "Owen Mortensen" <(E-Mail Removed)> wrote in message
> news:e$(E-Mail Removed)...
>> So, I changed container.dataitem("CatID") to
>> container.dataitem("CatID").ToString() ... still get the same error. I do
>> not know how this construct works: something I copied out of a book....
>> Is there an explanation somewhere documented?
>>
>> Owen
>>
>> "Marina Levit [MVP]" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> container.dataitem("CatID") does not return a string - it returns an
>>> object. You are not explicitly casting it to a string, so that is your
>>> problem.
>>>
>>> "Owen Mortensen" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> (This code was working in asp.net 1.1 VS2003. After upgrade to VS2005,
>>>> chokes):
>>>>
>>>> in the aspx file:
>>>>
>>>> <ItemTemplate>
>>>> <asp:datagrid id="dg_instr" runat="server" AutoGenerateColumns="False"
>>>> HeaderStyle-Font-Bold="True"
>>>> CellPadding="0" CellSpacing="1" Font-Size="Small"
>>>> BackColor="Transparent" ForeColor="Black"
>>>> BorderStyle="None" BorderColor="#CCCCFF"
>>>> DataSource=<%#
>>>> buildInstrumentListDataGrid(container.dataitem("Ca tID"))%>>
>>>>
>>>> I get the error: Option Strict On disallows late binding
>>>>
>>>> What item is being late-bound? And how do I not late-bind it?
>>>>
>>>> Here's the function:
>>>>
>>>> Function buildInstrumentListDataGrid(ByVal CatID As String) As
>>>> DataTable
>>>> Dim lp_survey_Connect As New dBUtils("sConnectLPSurvey")
>>>> Dim strInstrSQLQuery As String
>>>> Dim objInstrDataSet As New DataSet
>>>>
>>>> strInstrSQLQuery = "SELECT InstID, InstName, CatID" & _
>>>> " FROM InstrumentList" & _
>>>> " WHERE CatID = " & CatID & " ORDER BY InstID"
>>>>
>>>> objInstrDataSet = lp_survey_Connect.GetDataSet(strInstrSQLQuery,
>>>> False)
>>>> lp_survey_Connect.Dispose()
>>>>
>>>> Return objInstrDataSet.Tables(0)
>>>>
>>>> End Function
>>>>
>>>> Thanks,
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --------------------------------------------------------------------------------
>>>> Owen
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Owen Mortensen
Guest
Posts: n/a
 
      03-10-2006
Doh!. The line causing the compile time error is the "<asp:datagrid...."
line

"Marina Levit [MVP]" <(E-Mail Removed)> wrote in message
news:e%(E-Mail Removed)...
> Well, this was one spot where I could see this being a problem - you did
> not tell us what line number is actually causing the compile time error,
> or whether or not you are using code behind.
> I am sort of surprised that an upgrade to 2005 would cause this. I have
> not encountered any Option Strict differences when upgrading code.
>
> "Owen Mortensen" <(E-Mail Removed)> wrote in message
> news:e$(E-Mail Removed)...
>> So, I changed container.dataitem("CatID") to
>> container.dataitem("CatID").ToString() ... still get the same error. I do
>> not know how this construct works: something I copied out of a book....
>> Is there an explanation somewhere documented?
>>
>> Owen
>>
>> "Marina Levit [MVP]" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> container.dataitem("CatID") does not return a string - it returns an
>>> object. You are not explicitly casting it to a string, so that is your
>>> problem.
>>>
>>> "Owen Mortensen" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> (This code was working in asp.net 1.1 VS2003. After upgrade to VS2005,
>>>> chokes):
>>>>
>>>> in the aspx file:
>>>>
>>>> <ItemTemplate>
>>>> <asp:datagrid id="dg_instr" runat="server" AutoGenerateColumns="False"
>>>> HeaderStyle-Font-Bold="True"
>>>> CellPadding="0" CellSpacing="1" Font-Size="Small"
>>>> BackColor="Transparent" ForeColor="Black"
>>>> BorderStyle="None" BorderColor="#CCCCFF"
>>>> DataSource=<%#
>>>> buildInstrumentListDataGrid(container.dataitem("Ca tID"))%>>
>>>>
>>>> I get the error: Option Strict On disallows late binding
>>>>
>>>> What item is being late-bound? And how do I not late-bind it?
>>>>
>>>> Here's the function:
>>>>
>>>> Function buildInstrumentListDataGrid(ByVal CatID As String) As
>>>> DataTable
>>>> Dim lp_survey_Connect As New dBUtils("sConnectLPSurvey")
>>>> Dim strInstrSQLQuery As String
>>>> Dim objInstrDataSet As New DataSet
>>>>
>>>> strInstrSQLQuery = "SELECT InstID, InstName, CatID" & _
>>>> " FROM InstrumentList" & _
>>>> " WHERE CatID = " & CatID & " ORDER BY InstID"
>>>>
>>>> objInstrDataSet = lp_survey_Connect.GetDataSet(strInstrSQLQuery,
>>>> False)
>>>> lp_survey_Connect.Dispose()
>>>>
>>>> Return objInstrDataSet.Tables(0)
>>>>
>>>> End Function
>>>>
>>>> Thanks,
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --------------------------------------------------------------------------------
>>>> Owen
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Owen Mortensen
Guest
Posts: n/a
 
      03-13-2006
I STILL do not know how to fix the error. Which part of the
<asp:datagrid.... declaration is tossing the error and why? What type is it
looking for?

HELP?

"Owen Mortensen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Doh!. The line causing the compile time error is the "<asp:datagrid...."
> line
>
> "Marina Levit [MVP]" <(E-Mail Removed)> wrote in message
> news:e%(E-Mail Removed)...
>> Well, this was one spot where I could see this being a problem - you did
>> not tell us what line number is actually causing the compile time error,
>> or whether or not you are using code behind.
>> I am sort of surprised that an upgrade to 2005 would cause this. I have
>> not encountered any Option Strict differences when upgrading code.
>>
>> "Owen Mortensen" <(E-Mail Removed)> wrote in message
>> news:e$(E-Mail Removed)...
>>> So, I changed container.dataitem("CatID") to
>>> container.dataitem("CatID").ToString() ... still get the same error. I
>>> do not know how this construct works: something I copied out of a
>>> book.... Is there an explanation somewhere documented?
>>>
>>> Owen
>>>
>>> "Marina Levit [MVP]" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> container.dataitem("CatID") does not return a string - it returns an
>>>> object. You are not explicitly casting it to a string, so that is your
>>>> problem.
>>>>
>>>> "Owen Mortensen" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> (This code was working in asp.net 1.1 VS2003. After upgrade to VS2005,
>>>>> chokes):
>>>>>
>>>>> in the aspx file:
>>>>>
>>>>> <ItemTemplate>
>>>>> <asp:datagrid id="dg_instr" runat="server" AutoGenerateColumns="False"
>>>>> HeaderStyle-Font-Bold="True"
>>>>> CellPadding="0" CellSpacing="1" Font-Size="Small"
>>>>> BackColor="Transparent" ForeColor="Black"
>>>>> BorderStyle="None" BorderColor="#CCCCFF"
>>>>> DataSource=<%#
>>>>> buildInstrumentListDataGrid(container.dataitem("Ca tID"))%>>
>>>>>
>>>>> I get the error: Option Strict On disallows late binding
>>>>>
>>>>> What item is being late-bound? And how do I not late-bind it?
>>>>>
>>>>> Here's the function:
>>>>>
>>>>> Function buildInstrumentListDataGrid(ByVal CatID As String) As
>>>>> DataTable
>>>>> Dim lp_survey_Connect As New dBUtils("sConnectLPSurvey")
>>>>> Dim strInstrSQLQuery As String
>>>>> Dim objInstrDataSet As New DataSet
>>>>>
>>>>> strInstrSQLQuery = "SELECT InstID, InstName, CatID" & _
>>>>> " FROM InstrumentList" & _
>>>>> " WHERE CatID = " & CatID & " ORDER BY InstID"
>>>>>
>>>>> objInstrDataSet = lp_survey_Connect.GetDataSet(strInstrSQLQuery,
>>>>> False)
>>>>> lp_survey_Connect.Dispose()
>>>>>
>>>>> Return objInstrDataSet.Tables(0)
>>>>>
>>>>> End Function
>>>>>
>>>>> Thanks,
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --------------------------------------------------------------------------------
>>>>> Owen
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Option Strict On disallows late binding Seema ASP .Net 1 01-25-2012 02:19 AM
Error: Option strict disallows late binding Adotek ASP .Net 1 10-03-2006 05:50 PM
Option Strict On disallows late binding Chris Davey via .NET 247 ASP .Net Datagrid Control 1 04-06-2005 05:29 PM
Option Strict On disallows late binding. Ryan McLean ASP .Net 3 06-14-2004 05:49 PM
option strict disallows late binding reading from web.config Karl Lang ASP .Net 1 06-01-2004 10:56 AM



Advertisments