Specified cast error on an integer datatype

N

.Net Sports

I have a datagrid codebehind script that takes data from sql dbase and
displays it in a footer row as a total. One column has amount_dollars
(which works fine), while another has new sales (which is "newstotal"),
but I'm getting an error (System.InvalidCastException: Specified cast
is not valid) from the newstotal line:

price = (Decimal)(rowData["Amount_Dollars"]);
newstotal = (rowData["News"]);

newstotal is an integer, just wondering what datatype i should use
(whereas 'price' is a money datatype, and I can format it as Decimal,
but I just want the newstotal to be a simple integer. )Using (Integer)
or (short) in front of (rowData["News"]); give me the Specified cast
not valid error.

????
..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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top