Specified Cast with no reference to line with problem

N

.Net Sports

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
 
J

Jeff Barnes

Can you post the stack trace from the exception?

Jeff Barnes
Microsoft Certified Application Developer
 
N

.Net Sports

[InvalidCastException: Specified cast is not valid.]
TotalsProject.TotalsResult.dg1_ItemDataBound(Object sender,
DataGridItemEventArgs e)
System.Web.UI.WebControls.DataGridItemEventHandler.Invoke(Object
sender, DataGridItemEventArgs e) +0
System.Web.UI.WebControls.DataGrid.OnItemDataBound(DataGridItemEventArgs
e) System.Web.UI.WebControls.DataGrid.CreateItem(Int32 itemIndex, Int32
dataSourceIndex, ListItemType itemType, Boolean dataBind, Object
dataItem, DataGridColumn[] columns, TableRowCollection rows,
PagedDataSource pagedDataSource)
System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
useDataSource)
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
System.Web.UI.WebControls.BaseDataList.DataBind()
TotalsProject.TotalsResult.Page_Load(Object sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()


whereas TotalsProject is project name, TotalsResult is the aspx
script/page, dg1 is the datagrid ID.
Thanks
NetSports
 
J

Jeff Barnes

The stack trace indicates that the error is occurring in
dg1_ItemDataBound. 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
 
N

.Net Sports

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top