Good afternoon,
I have a very strange problem. When I execute the code below the
program throws an InvalidCastExce ption. When I debug the code I see
e.Item.DataItem is an object from the type OrganisatieOnde rdeel. When
you read the additional you can see the types are the same. How can I
solve this problem?
Kinds regards,
Lammert
Code:
protected void fvwContact_Item DataBound(objec t sender,
DataListItemEve ntArgs e)
{
ObjectDataSourc e ods = new ObjectDataSourc e();
ods.TypeName = "BusinessLogicL ayer.FunctieVer vulling";
ods.SelectMetho d = "GetFunctieVerv ullingenById";
// An exception of type 'System.Invalid CastException' occurred in this
this line:
OrganisatieOnde rdeel oo =
(OrganisatieOnd erdeel)e.Item.D ataItem;
ods.SelectParam eters.Add("id", TypeCode.Int32,
oo.Id.ToString( ));
DataList ds = (DataList)e.Ite m.FindControl(" dlPersonen");
ds.DataSource = ods;
ds.DataBind();
}
Message:
An exception of type 'System.Invalid CastException' occurred in
WebApp.DLL but was not handled in user code
Additional information: Unable to cast object of type
'BusinessLogicL ayer.Organisati eOnderdeel' to type
'BusinessLogicL ayer.Organisati eOnderdeel'. 4 2050
Lammert,
You have to filter out all non-data items with something like this:
ListItemType itemType = e.Item.ItemType ;
if ((itemType == ListItemType.Pa ger) ||
(itemType == ListItemType.He ader) ||
(itemType == ListItemType.Fo oter))
{
return;
}
Eliyahu
"Lammert" <lv****@hotmail .com> wrote in message
news:11******** *************@b 68g2000cwa.goog legroups.com... Good afternoon,
I have a very strange problem. When I execute the code below the program throws an InvalidCastExce ption. When I debug the code I see e.Item.DataItem is an object from the type OrganisatieOnde rdeel. When you read the additional you can see the types are the same. How can I solve this problem?
Kinds regards, Lammert
Code: protected void fvwContact_Item DataBound(objec t sender, DataListItemEve ntArgs e) { ObjectDataSourc e ods = new ObjectDataSourc e(); ods.TypeName = "BusinessLogicL ayer.FunctieVer vulling"; ods.SelectMetho d = "GetFunctieVerv ullingenById";
// An exception of type 'System.Invalid CastException' occurred in this this line: OrganisatieOnde rdeel oo = (OrganisatieOnd erdeel)e.Item.D ataItem;
ods.SelectParam eters.Add("id", TypeCode.Int32, oo.Id.ToString( )); DataList ds = (DataList)e.Ite m.FindControl(" dlPersonen"); ds.DataSource = ods; ds.DataBind(); }
Message: An exception of type 'System.Invalid CastException' occurred in WebApp.DLL but was not handled in user code
Additional information: Unable to cast object of type 'BusinessLogicL ayer.Organisati eOnderdeel' to type 'BusinessLogicL ayer.Organisati eOnderdeel'.
This doesn't work. When I cast an Object (OrganisatieOnd erdeel) to
OrganisatieOnde rdeel the program throws an InvalidCastExce ption. For
example e.Item.DataItem contains an Object of the type
OrganisatieOnde rdeel, but I can't cast this to OrganisatieOnde rdeel!!
Are there any solutions??
Eliyahu Goldin schreef: Lammert,
You have to filter out all non-data items with something like this:
ListItemType itemType = e.Item.ItemType ;
if ((itemType == ListItemType.Pa ger) ||
(itemType == ListItemType.He ader) ||
(itemType == ListItemType.Fo oter))
{
return;
} Eliyahu
"Lammert" <lv****@hotmail .com> wrote in message news:11******** *************@b 68g2000cwa.goog legroups.com... Good afternoon,
I have a very strange problem. When I execute the code below the program throws an InvalidCastExce ption. When I debug the code I see e.Item.DataItem is an object from the type OrganisatieOnde rdeel. When you read the additional you can see the types are the same. How can I solve this problem?
Kinds regards, Lammert
Code: protected void fvwContact_Item DataBound(objec t sender, DataListItemEve ntArgs e) { ObjectDataSourc e ods = new ObjectDataSourc e(); ods.TypeName = "BusinessLogicL ayer.FunctieVer vulling"; ods.SelectMetho d = "GetFunctieVerv ullingenById";
// An exception of type 'System.Invalid CastException' occurred in this this line: OrganisatieOnde rdeel oo = (OrganisatieOnd erdeel)e.Item.D ataItem;
ods.SelectParam eters.Add("id", TypeCode.Int32, oo.Id.ToString( )); DataList ds = (DataList)e.Ite m.FindControl(" dlPersonen"); ds.DataSource = ods; ds.DataBind(); }
Message: An exception of type 'System.Invalid CastException' occurred in WebApp.DLL but was not handled in user code
Additional information: Unable to cast object of type 'BusinessLogicL ayer.Organisati eOnderdeel' to type 'BusinessLogicL ayer.Organisati eOnderdeel'.
Did you check in the debugger that e.Item.DataItem indeed is an object of
the type
OrganisatieOnde rdeel?
Eliyahu
"Lammert" <lv****@hotmail .com> wrote in message
news:11******** *************@d 56g2000cwd.goog legroups.com... This doesn't work. When I cast an Object (OrganisatieOnd erdeel) to OrganisatieOnde rdeel the program throws an InvalidCastExce ption. For example e.Item.DataItem contains an Object of the type OrganisatieOnde rdeel, but I can't cast this to OrganisatieOnde rdeel!! Are there any solutions??
Eliyahu Goldin schreef:
Lammert,
You have to filter out all non-data items with something like this:
ListItemType itemType = e.Item.ItemType ;
if ((itemType == ListItemType.Pa ger) ||
(itemType == ListItemType.He ader) ||
(itemType == ListItemType.Fo oter))
{
return;
} Eliyahu
"Lammert" <lv****@hotmail .com> wrote in message news:11******** *************@b 68g2000cwa.goog legroups.com... > Good afternoon, > > I have a very strange problem. When I execute the code below the > program throws an InvalidCastExce ption. When I debug the code I see > e.Item.DataItem is an object from the type OrganisatieOnde rdeel. When > you read the additional you can see the types are the same. How can I > solve this problem? > > Kinds regards, > Lammert > > > Code: > protected void fvwContact_Item DataBound(objec t sender, > DataListItemEve ntArgs e) > { > ObjectDataSourc e ods = new ObjectDataSourc e(); > ods.TypeName = "BusinessLogicL ayer.FunctieVer vulling"; > ods.SelectMetho d = "GetFunctieVerv ullingenById"; > > // An exception of type 'System.Invalid CastException' occurred in this > this line: > OrganisatieOnde rdeel oo = > (OrganisatieOnd erdeel)e.Item.D ataItem; > > ods.SelectParam eters.Add("id", TypeCode.Int32, > oo.Id.ToString( )); > DataList ds = (DataList)e.Ite m.FindControl(" dlPersonen"); > ds.DataSource = ods; > ds.DataBind(); > } > > Message: > An exception of type 'System.Invalid CastException' occurred in > WebApp.DLL but was not handled in user code > > Additional information: Unable to cast object of type > 'BusinessLogicL ayer.Organisati eOnderdeel' to type > 'BusinessLogicL ayer.Organisati eOnderdeel'. >
Yes, I do!!
Eliyahu Goldin schreef: Did you check in the debugger that e.Item.DataItem indeed is an object of the type OrganisatieOnde rdeel?
Eliyahu
"Lammert" <lv****@hotmail .com> wrote in message news:11******** *************@d 56g2000cwd.goog legroups.com... This doesn't work. When I cast an Object (OrganisatieOnd erdeel) to OrganisatieOnde rdeel the program throws an InvalidCastExce ption. For example e.Item.DataItem contains an Object of the type OrganisatieOnde rdeel, but I can't cast this to OrganisatieOnde rdeel!! Are there any solutions??
Eliyahu Goldin schreef:
Lammert,
You have to filter out all non-data items with something like this:
ListItemType itemType = e.Item.ItemType ;
if ((itemType == ListItemType.Pa ger) ||
(itemType == ListItemType.He ader) ||
(itemType == ListItemType.Fo oter))
{
return;
} Eliyahu
"Lammert" <lv****@hotmail .com> wrote in message news:11******** *************@b 68g2000cwa.goog legroups.com... > Good afternoon, > > I have a very strange problem. When I execute the code below the > program throws an InvalidCastExce ption. When I debug the code I see > e.Item.DataItem is an object from the type OrganisatieOnde rdeel. When > you read the additional you can see the types are the same. How can I > solve this problem? > > Kinds regards, > Lammert > > > Code: > protected void fvwContact_Item DataBound(objec t sender, > DataListItemEve ntArgs e) > { > ObjectDataSourc e ods = new ObjectDataSourc e(); > ods.TypeName = "BusinessLogicL ayer.FunctieVer vulling"; > ods.SelectMetho d = "GetFunctieVerv ullingenById"; > > // An exception of type 'System.Invalid CastException' occurred in this > this line: > OrganisatieOnde rdeel oo = > (OrganisatieOnd erdeel)e.Item.D ataItem; > > ods.SelectParam eters.Add("id", TypeCode.Int32, > oo.Id.ToString( )); > DataList ds = (DataList)e.Ite m.FindControl(" dlPersonen"); > ds.DataSource = ods; > ds.DataBind(); > } > > Message: > An exception of type 'System.Invalid CastException' occurred in > WebApp.DLL but was not handled in user code > > Additional information: Unable to cast object of type > 'BusinessLogicL ayer.Organisati eOnderdeel' to type > 'BusinessLogicL ayer.Organisati eOnderdeel'. > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alan Z. Scharf |
last post by:
Win Server 2003
VS.Net 2003
---------------
1. I'm having the same problem below on all six of my pages with a
datagrid
item.
2. These pages all worked fine for months until problem started.
3. Same problem on two different computers running Win 2003.
|
by: Nick Flandry |
last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my
development environment (Win2K server running IIS 5) and a test environment (also Win2K server
running IIS 5), but fails on IIS 6 running on a Win2003 server.
The web uses Pages derived from a custom class I wrote (which itself derives from Page) to provide
some common functionality. The Page_Load handler the failing webpage starts out like this:
...
|
by: John Howard |
last post by:
Making the following call to a local MSAccess database works fine:
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim intRows As Integer
Dim strSQL As String
Dim ds As New DataSet
' Create connection
Dim cn As New OleDbConnection
With cn
.connectionstring =
|
by: Hifni Shahzard |
last post by:
Hi,
I got a stored procedure, where it returns a value. But if I execute it. It
gives an error as "Invalid cast from System.Int32 to System.Byte.". To make
clear how do I execute this, below I'm specifiying my code:
The Code used in Visual Studio:
Function GetRank(ByVal ID As Integer, ByVal Comp As String, ByVal Sec As
String, ByVal iDate As Date) As String
'Dim Ret As Integer
|
by: buzz |
last post by:
I am attempting to pass data between two asp.net web forms pages. I
have found the method to do this on the msdn site here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconPassingServerControlValuesBetweenPages.asp
After attempting to do this myself, I kept getting an Invalid Cast
Exception error, so I finally resorted to simply copying and pasting
the MS code in this article into two pages for the...
| |
by: David |
last post by:
Hi,
I have built a web application that will be a very high profile application.
We had tested it, demonstrated it and shown that it all works.
On a dress rehearsal run through, it failed spectacularly. I was so
embarrassed and felt like killing the person that made it fail. However,
when it goes live, IT MUST NOT FAIL.
The system has a backoffice system that takes an excel spreadsheet from the
|
by: John Howard |
last post by:
Making the following call to a local MSAccess database works fine:
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim intRows As Integer
Dim strSQL As String
Dim ds As New DataSet
' Create connection
Dim cn As New OleDbConnection
With cn
.connectionstring = "provider=Microsoft.Jet.OLEDB.4.0;" & _
|
by: cs_hart |
last post by:
I am getting an invalid cast exception - cast from string to type
double is not valid.
Dim curName As String
Dim prevName As String = ""
curName = CStr(rows.Item(i).Item(colSchName)) ' extract name from
database row
If (curName.CompareTo(prevName <> 0)) Then <--- exception occurs on
this line
|
by: Chris Thunell |
last post by:
I'm trying to loop through an exchange public folder contact list, get some
information out of each item, and then put it into a vb.net datatable. I
run though the code and all works fine until i get to item 250 i get a
"system.invalid cast exception" and "specified cast is not valid". Once i
get this error and try to go to the next record.. every record after gets
the same error... It's like the com connection to outlook has been lost....
|
by: batmanfreeze |
last post by:
I am using C# in .Net 1.1, and need to access the 'Client' Property of TcpClient, so I created a derived class to do this based upon the Microsoft Sample, located at:
http://msdn2.microsoft.com/en-us/library/system.net.sockets.tcpclient.client(VS.71).aspx
The only problem is that in my main app, when I try to do the following, I get an Invalid Cast Exception:
int PortNum = 10000;
TcpListener objTcpListen = new...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |