Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1205
Ultra Combo - checking for null
posted

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

{

 

 

 

 

GridLayout.UserID = Convert.ToInt32(ucUserName.ActiveRow.Cells["UserID"].Value.ToString

());

}