decimal getTotalValue(GridView view, int listSourceRowIndex) { decimal unitPrice = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "Each")); //Object cannot be cast from DBNull to other types decimal quantity = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "Quantity")); decimal discount = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "TaxPercentage")); return unitPrice * quantity * (1 - discount); } private void gridView1_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e) { GridView view = sender as GridView; if (e.Column.FieldName == "Totalototal" && e.IsGetData) e.Value = getTotalValue(view, e.ListSourceRowIndex); }
NULL
null
string value = view.GetListSourceRowCellValue(listSourceRowIndex, "Each") +"" ; decimal unitPrice; decimal.TryParse(value, out unitPrice);
decimal unitPrice = Convert.ToDecimal(view.GetListSourceRowCellValue(listSourceRowIndex, "Each").Value);
I'm thinking that your output parameter is coming back with a DBNull value. Add a check for that like this
var outputParam = dataAccCom.GetParameterValue(IDbCmd, "op_Id"); if(!(outputParam is DBNull)) DataTO.Id = Convert.ToInt64(outputParam);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)