473,657 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Specified Cast with no reference to line with problem

I'm getting a "Specified cast is not valid" error that does not point
to the line with the code in error, but instead :An unhandled exception
was generated during the execution of the current web request.
Information regarding the origin and location of the exception can be
identified using the exception stack trace below.

The stack trace is just a lot of system class stuff with no real
explanation of where the error is. Wondering the best way to decipher a
stack trace in such a case.
thanks
..NetSports

Nov 17 '05 #1
4 1306
Can you post the stack trace from the exception?

Jeff Barnes
Microsoft Certified Application Developer

..Net Sports wrote:
I'm getting a "Specified cast is not valid" error that does not point
to the line with the code in error, but instead :An unhandled exception
was generated during the execution of the current web request.
Information regarding the origin and location of the exception can be
identified using the exception stack trace below.

The stack trace is just a lot of system class stuff with no real
explanation of where the error is. Wondering the best way to decipher a
stack trace in such a case.
thanks
.NetSports

Nov 17 '05 #2
[InvalidCastExce ption: Specified cast is not valid.]
TotalsProject.T otalsResult.dg1 _ItemDataBound( Object sender,
DataGridItemEve ntArgs e)
System.Web.UI.W ebControls.Data GridItemEventHa ndler.Invoke(Ob ject
sender, DataGridItemEve ntArgs e) +0
System.Web.UI.W ebControls.Data Grid.OnItemData Bound(DataGridI temEventArgs
e) System.Web.UI.W ebControls.Data Grid.CreateItem (Int32 itemIndex, Int32
dataSourceIndex , ListItemType itemType, Boolean dataBind, Object
dataItem, DataGridColumn[] columns, TableRowCollect ion rows,
PagedDataSource pagedDataSource )
System.Web.UI.W ebControls.Data Grid.CreateCont rolHierarchy(Bo olean
useDataSource)
System.Web.UI.W ebControls.Base DataList.OnData Binding(EventAr gs e)
System.Web.UI.W ebControls.Base DataList.DataBi nd()
TotalsProject.T otalsResult.Pag e_Load(Object sender, EventArgs e)
System.Web.UI.C ontrol.OnLoad(E ventArgs e)
System.Web.UI.C ontrol.LoadRecu rsive()
System.Web.UI.P age.ProcessRequ estMain()
whereas TotalsProject is project name, TotalsResult is the aspx
script/page, dg1 is the datagrid ID.
Thanks
NetSports

Nov 17 '05 #3
The stack trace indicates that the error is occurring in
dg1_ItemDataBou nd. Set a breakpoint in that method and step through it.
You should be able to determine where the invalid cast is occurring.

I hope this helps.

Regards,

Jeff Barnes
Microsoft Certified Application Developer

..Net Sports wrote:
[InvalidCastExce ption: Specified cast is not valid.]
TotalsProject.T otalsResult.dg1 _ItemDataBound( Object sender,
DataGridItemEve ntArgs e)
System.Web.UI.W ebControls.Data GridItemEventHa ndler.Invoke(Ob ject
sender, DataGridItemEve ntArgs e) +0
System.Web.UI.W ebControls.Data Grid.OnItemData Bound(DataGridI temEventArgs
e) System.Web.UI.W ebControls.Data Grid.CreateItem (Int32 itemIndex, Int32
dataSourceIndex , ListItemType itemType, Boolean dataBind, Object
dataItem, DataGridColumn[] columns, TableRowCollect ion rows,
PagedDataSource pagedDataSource )
System.Web.UI.W ebControls.Data Grid.CreateCont rolHierarchy(Bo olean
useDataSource)
System.Web.UI.W ebControls.Base DataList.OnData Binding(EventAr gs e)
System.Web.UI.W ebControls.Base DataList.DataBi nd()
TotalsProject.T otalsResult.Pag e_Load(Object sender, EventArgs e)
System.Web.UI.C ontrol.OnLoad(E ventArgs e)
System.Web.UI.C ontrol.LoadRecu rsive()
System.Web.UI.P age.ProcessRequ estMain()
whereas TotalsProject is project name, TotalsResult is the aspx
script/page, dg1 is the datagrid ID.
Thanks
NetSports

Nov 17 '05 #4
I put a breakpoint there, but I can't find where a break window for
debugger is. The only choices for Stepping is Step In and Step over,
which does nothing to show me what line the error is.
?????
NetSports

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
28253
by: Jack MacRank | last post by:
Hello, I'm coding a webform application in C# (ASP.NET 1.1 SP1 with VS.NET 2003 Pro on WinXP SP2 using IIS 5.1). I created a seperate "data" class to house all the MySQL connection and sql command methods. This is exactly what the Microsoft Data Access Application Block assembly does but I coded my own simple, custom class. I have a method named "ExecuteAggregate" that takes in a sql string like
10
1784
by: Arjen | last post by:
Hello, Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Specified cast is not valid. Line 176. Source Error:
8
1797
by: Charles | last post by:
I do not understand why I am getting a "Specified cast is not valid" error, since it has worked before. Something has changed and I am not really sure what it could be. I am looking for something along the lines of did you check this, have you did this, or this is the wrong way of doing this. I can access the CColPositions and the CPosition class, but when I try to use the two classes in a For...Next loop I get the error message above. ...
3
2176
by: VB Programmer | last post by:
I am setting up forms authentication. In my code I keep getting this error. Any ideas? Error.... Server Error in '/LandOLots' Application. --------------------------------------------------------------------------------
0
1616
by: Alan Z. Scharf | last post by:
this question in datagrid group for several days with no repsonse. I'm hoping for an answer her because of greater activity in this group. No cross-posting intended. Thanks. ----------------------------------------------------------- Server VS.NET 2003 SQLServer 2000 IIS 66.0
3
1693
by: Mike Cooper | last post by:
Hello All! I am getting teh above error message on the following code: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dgt As DataGridTableStyle = Main_DataGrid.TableStyles(0) Dim cm As CurrencyManager = CType(Me.BindingContext _
1
1715
by: planet | last post by:
Hi, I wish I can solve this problem not having recode the sub. Here is goes: I got this error' specified cast is not valid' at the second line. from the code Sub ChkDelete_OnCheckedChanged(ByVal sender As Object, ByVal e As EventArgs) DataGrid1_DeleteCommand(sender, e)
8
4264
by: Gamma | last post by:
I'm trying to inherit subclass from System.Diagnostics.Process, but whenever I cast a "Process" object to it's subclass, I encounter an exception "System.InvalidCastException" ("Specified cast is not valid"). How do I fix it ? using System.Diagnostics; .. .. class NewProcess: Process {
2
3526
by: Kashiefah | last post by:
Hi, I keep on receiving this error when I click on the edit email link from the datagrid:Specified cast is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Specified cast is not valid. Source Error: Line 44: while...
0
8411
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, 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...
0
8323
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8838
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, 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...
0
8613
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
isladogs
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...
0
5638
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();...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2740
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
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.