473,395 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Datagrid: Option Strict On disallows late binding -- HELP

(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
7 2109
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Karl Lang | last post by:
Hi I've created a new configuration section in Web.Config to hold the connection string for my database. If I have Option Strict On I get a message "Option Strict On disallows late binding" when I...
12
by: Simon Harris | last post by:
Hi All, I've been advised to use option strict. I've tried to read up on this, all i can find is that it... "disallows implicit narrowing conversions" This kinda makes sense - Means I have...
11
by: Dieter Schwerdtfeger via DotNetMonster.com | last post by:
I have this function where i search through my database for items that were made on a specific date. The line "CType(dvClubs.Item(teller).Item(veld).ToShortDateString" gives me the error : option...
3
by: Starbuck | last post by:
Hi The following generates an error when Option Strict is On Can anytell tell me how to get round this please. Private Sub optWithTone_CheckedChanged(ByVal eventSender As System.Object, ByVal...
7
by: CodeMonkey | last post by:
Hi All the following code generates an error with option strict on - Option strict disallows late binding. Can someone please help with what needs to be changed: Dim sweep, totalsweep As...
4
by: Heinz | last post by:
Hi all, I use VB.net 2003 and want to export data to Excel. Target PCs still have Office 2000 so I could not use Microsofts PIAs. Instead I use the included Excel 10 COM DLL from Microsoft....
1
by: Adotek | last post by:
Hi All, I've just converted a solution from .Net v1.1 to v2.0, by allowing Visual Studio 2005 to do the conversion. Since doing so, I am getting a compilation error as follows: "Option...
7
by: Lynn | last post by:
Hello, I have a website that is working fine. I have just turned on "option strict" and am getting an error with the parts of my code. I have fixed everything but this section, which has me...
0
by: Ronald S. Cook | last post by:
Hi, I'm wanting to iterate over a generic IList, but the code won't compile because the blue sqiggle line under: _DataRow("SecurityFunctionName") = _IList(i).SecurityFunctionName; sez...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.