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.UltraWinGridImports Infragistics.Win.UltraWinEditorsPublic 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 SubEnd 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 columnNothing 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
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.
there's any news?
I'm unable to attach the sample, I get an error during submit.
You can download the sample here
http://www.isiformazione.it/download/max/Infragistics_Ultragrid_Combo_Null_issue.zip
I'm using the latest release WinForm 2010.3I use VB on Visual Studio 2010 targetting .Net 3.5.My computer is a Win 7 x64.Setting the nullable property on the grid column doesn't help.I've attached a small sample project demonstrating the issue.Thanks, Massimiliano