We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

"The input value is not a valid value for" error

Hi,

the cells of my SFDataGrid show me this "validation error":

"The input value is not a valid value for DevExpress.Xpo.XPCollection" when I try to select one of the object in a GridComboBoxColumn.

Example of this column:

sfDataGrid.Columns.Add(new GridComboBoxColumn()
{
    MappingName = "Category",
    HeaderText = "Category",
    DisplayMember = "Name",
    ValueMember = "Name",
    DropDownStyle = DropDownStyle.DropDownList,
    DataSource = dataSourceObjectSpace.GetObjects<Category>().ToList(),
    ValidationMode = Syncfusion.WinForms.DataGrid.Enums.GridValidationMode.None
});

The Category property is one of the property of the "grid row object" Item.

The grid datasource is assigned like:

grid.DataSource = dataSourceObjectSpace.GetObjects<Item>();

5 Replies

VD Vasanthkumar Durairaj Syncfusion Team December 19, 2022 04:28 PM UTC

Hi Saverio

We are a little unclear about your reported scenario. Please provide more information related to your query?

  • Details about your scenario with image illustrations       
  • Video illustration of your scenario
  • If possible, modify the attached file to reproduce the issue.

It will be more helpful for us to check the possibilities for resolving the reported problem.


Attachment: WF_SfDataGrid_17a3db6d.zip


SA Saverio December 19, 2022 09:15 PM UTC

Hi,

in your attached example, instead of using "Ship Country" as a simple string type, try to create the same property as a "Country" class type (more logical structure, for an OOP language); in that case, the column data source would become a list of Country objects, no longer a list of string.

Furthermore, how can I associate an enum type property to a column instead?



VD Vasanthkumar Durairaj Syncfusion Team December 20, 2022 02:35 PM UTC

Hi Saverio,

Find the response to the queries,

Query

Response

in your attached example, instead of using "Ship Country" as a simple string type, try to create the same property as a "Country" class type (more logical structure, for an OOP language); in that case, the column data source would become a list of Country objects, no longer a list of string.

We have modified the ShipCountry type as a country class type and the GridComboBoxColumn DataSource as a country object.

But we are unable to reproduce the reported issue from our end. Find the tested sample(WF_SfDataGrid_ComboBox).

If the issue persists, modify the attached sample to reproduce the issue.

Furthermore, how can I associate an enum type property to a column instead?

You can set the enum type property to the GridComboBox column.

Find the tested sample(WF_SfDataGrid_EnumComboBox)


Attachment: Samples_726a74ec.zip


SA Saverio replied to Vasanthkumar Durairaj December 20, 2022 11:31 PM UTC

Hi,

ok, I found how the enum columns works (I must create a new List of enums, populate it with the desired enums, and then assign to the desired column, strange behaviour, because I thought that was enough to assign directly the enum type to the "ColumnMemberType", but this is not the case, but ok, the important is that it works...), now I will try to resolve the first problem and I'll update you.

But I found another strange problem; the DateTime column crash the application (System.NullReferenceException), when I try to add a new row and then to edit it.

A sample of the column:

            sfDataGrid1.Columns.Add(new GridDateTimeColumn()
{
MappingName = "Date",
HeaderText = "Data",
ColumnMemberType = typeof(DateTime),
Pattern = DateTimePattern.ShortDate,
AllowNull = true
});




VS Vijayarasan Sivanandham Syncfusion Team December 21, 2022 01:27 PM UTC

Saverio,

Find the response to the queries,

Query

Response

 

ok, I found how the enum columns works (I must create a new List of enums, populate it with the desired enums, and then assign to the desired column, strange behaviour, because I thought that was enough to assign directly the enum type to the "ColumnMemberType", but this is not the case, but ok, the important is that it works...), now I will try to resolve the first problem and I'll update you.

 

Thanks for the update. Please test at your end. Also, please let us know if you require any further assistance on this. we will be happy to assist you.

 

But I found another strange problem; the DateTime column crash the application (System.NullReferenceException), when I try to add a new row and then to edit it.

 

A sample of the column:

 

            sfDataGrid1.Columns.Add(new GridDateTimeColumn()

            {

                MappingName = "Date",

                HeaderText = "Data",

                ColumnMemberType = typeof(DateTime),

                Pattern = DateTimePattern.ShortDate,

                AllowNull = true

            });

 

We have created a new thread for the query, and the link is below.
https://www.syncfusion.com/forums/179552/null-reference-exception-occurs-when-adding-a-new-row-for-the-datetime-column-type-in


Loader.
Live Chat Icon For mobile
Up arrow icon