How To Check DataRow Column To Correct Specified Cast Is Invalid



TODO:

Have you ever received a invalid cast exception, when checking the value of a column in a data row?

 

SOLUTION:

OrderNumber =  row.IsNull("ordernumber") ? "" : (string)row["ordernumber"];

 

NOTES:

OrderNumber above is a string, and row is a row in a DataTable



Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading