foreach (PropertyInfo PropertyItem in this.GetType().GetProperties())
{
PropertyItem.SetValue(this, objDataTable.Rows[0][PropertyItem.Name.ToString()], null);
}
In one of the loops i get this exceptional error:
Object of type 'System.DBNull' cannot be converted to type 'System.String'.
The error occurs because one of the fields in the database has no value (null), so the string property could not handle it. How can i convert this null to string?
If you know a shorter or better one, feel free to post it. I'm trying to avoid checking on every loop is current value is null or not.