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
1187
Unable to convert from '(null)' to 'System.Decimal'
posted

I have a grid bound to an ArrayList.  My arraylist is a list of business objects with various properties of types integer, decimal and string (never any nulls).  During the grid initializelayout, i am adding two custom columns with data types boolean and decimal.

when i add an object to my arraylist and try to set the value of one of the custom columns, i get a 'Data Error', 'Unable to convert from '(null)' to 'System.Decimal''.

How i'm adding the custom fields during initializelayout:

        If b.Columns.Exists("selected") = False Then
            c = b.Columns.Add("selected")
            c.DataType = GetType(Boolean)
            c.DefaultCellValue = True
            c.Nullable = Nullable.Disallow
        End If

        If b.Columns.Exists("listamount") = False Then
            c = b.Columns.Add("listamount")
            c.DataType = GetType(Decimal)
            c.DefaultCellValue = 0
            c.NullText = "0"
            c.Nullable = Nullable.Disallow
        End If

 

How I'm adding a new object to my arraylist:

    Private Sub AddOptionToSelected(ByVal optionid As Integer)
        Dim oi As New DealOptionItem
        oi.LoadBase(optionid)
        Dim i As Integer = Me.LIST.Add(oi)
        Me.grdOptions.DataBind()
        Dim row As UltraGridRow = Me.grdOptions.Rows.GetRowWithListIndex(i)
        row.Cells("selected").Value = True ' <---- this line shows the data error
        row.Cells("listamount").Value = oi.SALEAMOUNT
    End Sub

 

 

 

 

 

Parents
  • 469350
    Offline posted

    Hi,

    There's not much information here to go on. What version of the grid are you using?

    What does the call stack of the exception look like?

    It seems clear that your data source is unable to support null values, since you are using value types that are not nullable.

    There's no reason why the grid should be displaying an error about nulls if you are not actually using any.

Reply Children