DataTable dt1 = new DAL.DALHelper().getData(cmd);
if (dt.Rows.Count > 0)
{
int x = 0;
foreach (DataRow r in dt.Rows)
{
x += Convert.ToInt32(r["amount"]);
}
lblExpense.Text = x.ToString();
}
I am trying to SUM values. but there is so may NULL value so how I can total it? And my value is string value. showing this error(Object cannot be cast from DBNull to other types.)