StrataFrame Forum

Error displaying information in listview

http://forum.strataframe.net/Topic5558.aspx

By Michael Reese - 1/3/2007

I have a sf-form with a sflistview and sfcontrols. When I load the form, I get the errror below?? Some of the columns are intenionally null.

------------------------------------------------------------

Conversion from type 'DBNull' to type 'Integer' is not valid.

-------------------------------------------------------------

System.InvalidCastException was unhandled by user code
  Message="Conversion from type 'DBNull' to type 'Integer' is not valid."
  Source="Microsoft.VisualBasic"
  StackTrace:
       at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(Object Value)
       at ORION_BO.BOVendorContacts.get_PositionTitle() in N:\Development\Orion\ORION_BO\ORION_BO\Vendor\BOVendorContacts.designer.vb:line 428
       at ORION_BO.BOVendorContacts.Field_PositionTitle_Descriptor.GetValue(Object component) in N:\Development\Orion\ORION_BO\ORION_BO\Vendor\BOVendorContacts.designer.vb:line 1234
       at System.Windows.Forms.BindToObject.GetValue()
       at System.Windows.Forms.Binding.PushData(Boolean force)

By Trent L. Taylor - 1/3/2007

This is proper behavior.  If you have NULL fields you have to address them.  You can do this a number of different ways.  You can use the NULL options in the field customization within the BO Mapper or you can populate the column in the ListView using the PopulatedThroughEvent and handle the column population within the RowPopulating event.  You can then test on the NULL value and provide whatever value you would like for a NULL value.