我的代码是这样的对象不能从DBNull转换为显示的其他类型的错误?
private MyCatch _catch = new MyCatch("Description");
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);
}
嗨奈尔,Thankz很多 – Srihari