By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,869 Members | 1,756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,869 IT Pros & Developers. It's quick & easy.

Datagrid: Option Strict On disallows late binding -- HELP

P: n/a
(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
Mar 10 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a
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" <oj*********@acm.org> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
(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

Mar 10 '06 #2

P: n/a
OK. I don't know how to do that?

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

?

"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
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" <oj*********@acm.org> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
(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


Mar 10 '06 #3

P: n/a
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]" <so*****@nospam.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
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" <oj*********@acm.org> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
(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


Mar 10 '06 #4

P: n/a
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" <oj*********@acm.org> wrote in message
news:e$**************@TK2MSFTNGP11.phx.gbl...
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]" <so*****@nospam.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
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" <oj*********@acm.org> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
(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



Mar 10 '06 #5

P: n/a
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]" <so*****@nospam.com> wrote in message
news:e%****************@TK2MSFTNGP09.phx.gbl...
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" <oj*********@acm.org> wrote in message
news:e$**************@TK2MSFTNGP11.phx.gbl...
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]" <so*****@nospam.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
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" <oj*********@acm.org> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
(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



Mar 10 '06 #6

P: n/a
Doh!. The line causing the compile time error is the "<asp:datagrid...."
line

"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:e%****************@TK2MSFTNGP09.phx.gbl...
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" <oj*********@acm.org> wrote in message
news:e$**************@TK2MSFTNGP11.phx.gbl...
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]" <so*****@nospam.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
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" <oj*********@acm.org> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
(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



Mar 10 '06 #7

P: n/a
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" <oj*********@acm.org> wrote in message
news:uL**************@TK2MSFTNGP11.phx.gbl...
Doh!. The line causing the compile time error is the "<asp:datagrid...."
line

"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:e%****************@TK2MSFTNGP09.phx.gbl...
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" <oj*********@acm.org> wrote in message
news:e$**************@TK2MSFTNGP11.phx.gbl...
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]" <so*****@nospam.com> wrote in message
news:u3**************@TK2MSFTNGP10.phx.gbl...
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" <oj*********@acm.org> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
> (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
>



Mar 13 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.