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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridDataboundGrid: problems with binding business-objects with nullable types

Thread ID:

Created:

Updated:

Platform:

Replies:

95924 Aug 10,2010 12:55 PM UTC Mar 7,2018 11:40 AM UTC WinForms 15
loading
Tags: GridControl
Dani Knopf
Asked On August 10, 2010 12:55 PM UTC

Hi

We use the GridDataboundGrid and we have encountered a problem when binding businessobjects that have nullable properties (such as float?)

To add a new object, one normally just has to enter the values into the cells of the last (and empty) row. Upon the loosing the focus of that row, a new business object is created and added to the bound list. Usually, the user has to enter data in most cells, but in some cases null values are allowed.

However, this does not work, as a null value (of the cellvalue property) prevents the business object from being added.
(By the way: I experimented a bit with custom cells models and renderers and I have found out that the method OnRejectChanges of the renderer is being called but I have not found any event or overriden method where I can prevent this)


So my question is:

- What do I have to do to make the GridDataBoundGrid work with custom objects and nullable types. A custom objects needs to be created even when the nullable types columns are not set.

(to be more specific:
- is there a simple property of the column (styleinfo) to be set?)
- if not, is there an event in an custom cell model/renderer class that i can use?

Thanks in advance

Dan

Nirmal Raja [Syncfusion]
Replied On August 11, 2010 08:54 AM UTC

Hi Dan,

Thank you for your interest in Syncfusion products.

If the cell needs to accept the null values from the source then you have to set the AllowDBNull to true for each column of the grid.

Please refer to the code below:
(this.gridDataBoundGrid1.DataSource as DataTable).Columns[0].AllowDBNull = true;

Let me know if you have any concern.

Regards,
Nirmal

Dani Knopf
Replied On August 12, 2010 05:46 AM UTC

Hi

Thanks for your answer. Unfortunately, we use busines objects (from the entity framework) not a dataTable, so your solution does not apply.

What do I have to do to make the GridDataboundGrid work when the business objects have nullable properties (such as float?, short?)

Thanks

Jisha Joy [Syncfusion]
Replied On August 13, 2010 12:31 PM UTC

Hi Dani,

As long as the the underlying datasource supports nullable values, GridDataBound will allow null value to the cells. Can you please provide us a small sample shaowing the issue?. So that we could analyze it and provide you a solution based on it.

Regards,
Jisha

Dani Knopf
Replied On August 15, 2010 12:15 PM UTC

Hi

Attached a solution where the issue is reproducable. It may have something to do that we use entity objects that are attached to the context and not custom busines objects. I haven't been able to reproduce the issue with normal business objects.

Furthermore I found out, that it not only has something to do with nullable types but also with the dropdown showing the different types of enumerations.

Here is how to reproduce the issue with the attached solution:

1. Cursor is on name field: enter a name
2. Enter "Tab" to go to the next dropdown field -> move further to the next field via tab (the dropdown chooses the first entry in its datasource)
3. Click on the a field in another row. Normally, a new row should be added but this does not happen. (With our extended custom grid class-> the row should appear pink. Please also see the method CustomGrid.GetBoundObject(int rowIndex) that returns null in this case where it should return the newly added object.

Strangly, it works when i choose a value in the dropdown via mouse click or i enter a value in all nullable fields (such as float?).. Very strange to me.


Thanks in advance and greetings

Dan




PS: please dont mind some custom code in the CustomGrid class (inheriting from the GridDataboundGrid). Most of it does not yet work and does not influence the issue.



TestGridExtensions_2b008148.rar

Dani Knopf
Replied On August 19, 2010 06:37 AM UTC

Hi

Have you found the time to have a look at the issue?

Regards

Dan

Jisha Joy [Syncfusion]
Replied On August 19, 2010 11:29 AM UTC

Hi Dan,

Sorry for the delay in getting back to you. It seems that the edmx file provided in the sample seems to be corrupted. I was unable to run the sample. Could you please provide a sample that run without any errors.

Regards,
Jisha

Dani Knopf
Replied On August 19, 2010 01:58 PM UTC

Hi

Hopefully this time it works. (I tried the first upload and it work on my machine, maybe it has something to do with the version. I use Visual Studio 2010 Professional, .Net 4.0)

Greetings

Dan



TestGridExtensions_39d12ad1.rar

Dani Knopf
Replied On August 23, 2010 09:51 AM UTC

Hi

Have you been able to use the second upload?

Greetings

Dan

Jisha Joy [Syncfusion]
Replied On August 24, 2010 11:57 AM UTC

Hi Dan,

Sorry for the delay in getting back to you. Still I am not able to run the provided sample, it throws exceptions. Is it possible for you to provide a simple sample showing the issue?.

Regards,
Jisha

Dani Knopf
Replied On August 24, 2010 12:32 PM UTC

Hi

The path in the "App.config" to the database was fixed not relative. Probably, this was the cause for your exception. I have changed it now and it should work.

If not, can you tell me more about the type of exceptions? Unfortunately, the example needs a (embedded) database because I suspect the issue to be related to the entity framework.

Greetings and thanks in advance.

Dan



TestGridExtensions_eae8aa8.rar

Jisha Joy [Syncfusion]
Replied On August 26, 2010 07:13 AM UTC

Hi Dan,

Please follow up with your direct trac incident 71412 for the same query.

Regards,
Jisha

Dani Knopf
Replied On September 1, 2010 06:13 AM UTC

Thanks to the support, i could resolve the issue. I had to insert the following code:

//in FinalInitGrid() method
this.customGrid1.Binder.DefaultCurrentRecordItemChangedBehavior = GridCurrentRecordItemChangedBehavior.KeepCurrentRecord;

Greetings




Christopher Issac Sunder K [Syncfusion]
Replied On September 2, 2010 03:51 AM UTC

Hi Dan,

Thanks for the update.

Glad to know that issue got resolved on your side.

Thank you for using Syncfusion products.

Regards,
Christo.



Hassaan Sohail
Replied On March 6, 2018 10:00 AM UTC

Hi

Hopefully this time it works. (I tried the first upload and it work on my machine, maybe it has something to do with the version. I use Visual Studio 2010 Professional, .Net 4.0)

Greetings

Dan



TestGridExtensions_39d12ad1.rar

yes

Sindhu Nagarajan [Syncfusion]
Replied On March 7, 2018 11:40 AM UTC

Hi Dan, 
  
Please let us know whether you need any technical assistance. 
  
Regards, 
Sindhu  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;