I'm getting this error when I try to populate my page. The field can be null in the database, so how do I get around this?
Cast from type 'DBNull' to type 'String' is not valid.
Printable View
I'm getting this error when I try to populate my page. The field can be null in the database, so how do I get around this?
Cast from type 'DBNull' to type 'String' is not valid.
Try this:
Code:if(dr["Author"] == DBNull.Value) {
txtAuthor.Name = String.Empty;
}
else {
txtAuthor.Name = dr["Author"];
}
Also, isDBNull(avalue)
thanks guys...
I usedCode:If objDataReader("display_start_date") Is DBNull.Value Then
txtIntDisStartDate.Text = String.Empty
Else
txtIntDisStartDate.Text = ("display_start_date")
End If