When checking the below column for a value and the value is null, this error is returned:
Object reference not set to an instance of an object.
Values other than null process correctly. I also checked for a DBNull.Value.
I know of work arounds but it's not my preference.
Any help/ideas are appreciated.
Thanks.
if (ucUserName.ActiveRow.Cells["UserID"].Value == null) //DBNull.Value
{
GridLayout.UserID = 0;
}
else
());
Hello 2001plus,
I am glad that I was able to assist you here.
Please do not hesitate to contact us if you have any other questions.
Nice. Very nice.
Thanks Danko.
I think that at that particular moment you don't have an active row and that's why you are getting a null exception. In order to make sure that your code will be executed correctly, you could add a null check in your if clause before your code like:
if (ucUserName.ActiveRow !=null && ucUserName.ActiveRow.Cells["UserID"].Value == null)
Please feel free to let me know if you have any other questions with this matter.