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
180
Unable to select the Null / Nothing value in UltraDropDown, "Unable to update the data value: Value in the editor is not valid."
posted

I have a grid with a column set to an UltraDropDown in DropDownValidate style.
The combo represent a list of category, the underlying data is a nullable integer.
Null is a valid value that means "All the category".

The underliyng data of the grid is a typed list of a Class, the column are the properties of this class.
The underliyng data of the UltraDropDown is a typed list of another Class.

The issue is when I have a row with a category set to something, and I want to reset this row to "All categories". When I select the "All" from the dropdown list, and then change cell, the grid tell me "Unable to update the data value: Value in the editor is not valid.". It doesn't accept the value, ed keep me locked in the cell.
It weird because when I load the data from the DB, id a row have a null category, the UDD correctly show "All".

Here is the sample code to reproduce the issue:
Create a new form, create a new ultragrid in this form, and then paste the following code.
(it works only in VS 2010 because I use automatic implemented property in VB)

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

Imports Infragistics.Win.UltraWinGrid
Imports Infragistics.Win.UltraWinEditors

Public Class frmUltraGridComboNullIssue

    Private Class GridData
        Property IdKey As Integer
        Property IdCategoryData As Integer?
    End Class

    Private Class Category
        Property IdCategoryLookup As Integer?
        Property CategoryDesc As String
    End Class


    Dim listGrid As New List(Of GridData)
    Dim listLookup As New List(Of Category)


    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Init()
    End Sub

    Private Sub Init()
        Try
            listGrid.Add(New GridData With {.IdKey = 1, .IdCategoryData = 10})
            listGrid.Add(New GridData With {.IdKey = 2, .IdCategoryData = 20})
            listGrid.Add(New GridData With {.IdKey = 3, .IdCategoryData = 30})
            listGrid.Add(New GridData With {.IdKey = 4, .IdCategoryData = Nothing})
            'listGrid.Add(New GridData With {.IdKey = 5, .IdCategoryData = New Nullable(Of Integer)})


            listLookup.Add(New Category With {.IdCategoryLookup = 10, .CategoryDesc = "Category 10"})
            listLookup.Add(New Category With {.IdCategoryLookup = 20, .CategoryDesc = "Category 20"})
            listLookup.Add(New Category With {.IdCategoryLookup = 30, .CategoryDesc = "Category 30"})
            listLookup.Add(New Category With {.IdCategoryLookup = 40, .CategoryDesc = "Category 40"})
            listLookup.Add(New Category With {.IdCategoryLookup = Nothing, .CategoryDesc = "(ALL - nothing)"})
            'listLookup.Add(New Category With {.IdCategoryLookup = New Nullable(Of Integer), .CategoryDesc = "(ALL - nullable)"})


            Me.UltraGrid1.SetDataBinding(listGrid, "")

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub uGrid_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout
        Try

            Dim dropDown As New UltraDropDown

            dropDown.ValueMember = "IdCategoryLookup"
            dropDown.DisplayMember = "CategoryDesc"

            dropDown.SetDataBinding(listLookup, "")

            e.Layout.Bands(0).Columns("IdCategoryData").ValueList = dropDown
            e.Layout.Bands(0).Columns("IdCategoryData").Style = ColumnStyle.DropDownValidate


        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

End Class

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

I've tried many variations for the dropdown:
using a datatable for the dataSource, using anonymous type for the datasource, using object / integer / Nullable(of integer) /nothing / DBNull in the ID column
Nothing works, the sample code show the best results.

The underlying data of the grid must be a class, this can't be changed, it's our entity-based DAL.

Thank, Massimiliano

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    What version of the grid are you using? I'm pretty sure there was a bug where the grid wasn't properly dealing with nullable types in cases like this. That bug was fixed a while ago. So you could get try getting the latest service release and see if that corrects the issue. 

    How to get the latest service release - Infragistics Community

    Or, if you don't want to do that, try setting the Nullable property on the grid column to Nothing.

    If none of that works, see if you can create a small sample project demonstrating the issue so we can check it out. It's very hard to create a working sample from a code snippet like you have here, because it's missing all kinds of information like what version of the controls you are using.

     

Children