Changing datasource stopping application

Hi,


I have problem with SfDataGrid when I change DataSource. I found this topic but it doesn't work 

Refresh grid content after changing datasource 2018 | WinForms Forums | Syncfusion

For some reasons I have to change DataSource to collect data from MS SQL Server (I need to show data from another View because it collects data for different period of time). Structure of columns are the same.

I tried to add suggested lines form above topic but it doesn't work.

Image_1346_1721490512797

I am sending you video to show you what is happening.

Everything I do on SfDataGrid works OK if I don't change DataSource.

I use VB.net for coding .Net Framework 4.8.1 so if you have some examples or code, please write it in vb.net.

Thank you


Regards,

Sabian



Attachment: SfDataGrid__Change_data_source__8585748b.zip

7 Replies

SG Santhosh Govindasamy Syncfusion Team July 22, 2024 02:16 PM UTC

Hi Sabian Sirius,


Based on our analysis of the reported scenario, we would like to inform you that the Datasource does not accept a string type. Assigning an empty string ("") is not valid. If you need to update the datasource at runtime, please set the current datasource to null before assigning the new collection to it.

Additionally, kindly share the details of why you assigned an empty string to the datasource.

This information will be helpful for further follow-ups.

For your reference, I have attached a simple sample. Please take a look at it.

Code Snippet

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click

      sfDataGrid1.DataSource =Nothing

      sfDataGrid1.ClearGrouping()

      sfDataGrid1.ClearSorting()

      sfDataGrid1.ClearFilters()

      sfDataGrid1.TableSummaryRows.Clear()

      sfDataGrid1.GroupSummaryRows.Clear()

      sfDataGrid1.DataSource=table

 

End Sub


Regards,
Santhosh.G


Attachment: VB_sample_54e8256d.zip


SS Sabian Sirius July 24, 2024 07:02 AM UTC

Hi  Santhosh.G,

I made changes in my application, but it didn't help. I am sending you a video.

Image_1586_1721804415189


Image_5330_1721804383151

I have also started your example, and everything worked fine. 

Maybe there is something in fact that I am using Group View instead plain grid.

There is an interesting behavior. When I enter in application first time (after turning on computer) application doesn't stop immediately when I change datasource. I change data source once and then I get back (change data source once again and do that maybe once again) and then app stops. But when I start application second or third time it stops immediately after first change of datasource. 

Do you have any idea what is happening. If you need, I will sand additional data and all that is necessary to solve this.


Thank you 


Attachment: SfDataGrid__Changing_DataSource_causes_to_stop__2_e69d6bf9.zip


SG Santhosh Govindasamy Syncfusion Team July 25, 2024 10:51 AM UTC

Hi Sabian Sirius,

We would like to inform you that, as you mentioned, we tried to replicate the issue using Groups instead of a plain grid. However, we were unable to replicate the issue on our end; it worked as expected.

To proceed further, could you please share the details of the type of data used during the runtime when changing the datasource process? A code snippet illustrating this would be very helpful for us to assist you further.

Thank you for your cooperation. We look forward to your response.

Regards,

Santhosh.G





SS Sabian Sirius July 28, 2024 04:37 PM UTC

Hi Santhosh.G,


thank you for your efforts to solve this. I am sending forms where I use SfDataGrid. I added word file to explain how forms work. Also, I put text file with output from VS when this exception happens and backup of database I use in this forms. 


If anything else is needed I will send you.


And one more thing if it is Ok, I noticed that TotalSummaryRow is not displayed OK when there are records in SfDataGrid and when there are no records


With records (everything is fine)

Image_8723_1722184487902


Without records (there is some duplicate display of text)

Image_9723_1722184553829


Thak you once again. I hope that we will find solution.


Best regards,

Sabian


Attachment: Changing_datasource_causes_app_to_stop__OnMouseHover_f2b130ac.zip


MA Manikanda Akash Munisamy Syncfusion Team July 29, 2024 03:24 PM UTC

Hi Sabian,

We have created a simple sample using two DataTables with different views, which we have assigned as the DataSource for SfDataGrid at runtime. Following the steps demonstrated in your video, including searching cell values and modifying the DataSource, we were unable to reproduce the described exception.

We have attached the sample for your review. Please examine it and let us know if you can replicate the exception with this sample. If you cannot reproduce the exception, we will provide a patch that includes necessary null checks in the OnMouseHoverLeave event to address this problem.

We appreciate your cooperation and look forward to your feedback. Should you have any further questions or need additional information, please feel free to reach out.

Regards,
Manikanda Akash


Attachment: SfDatagrid_Demo_e3caaf99.zip


SS Sabian Sirius July 31, 2024 01:41 PM UTC

Hi  Manikanda Akash,


Thank you for your replay. I will review your sample. I think that may be the problem is in connecting database (MS SQL Server with grid).  I will try to rearrange my database and look what happens. All your previous samples for SfDataGrid were with data generated within program and there were no problems thet is why I want to check my database. 


Also, please can you check why  TotalSummaryRow, when there are no records, display same text twice (one above another - Look my previous replay)


Thank you very much. As soon as I check your sample and change my database, I will send new information.


Best regards,

Sabian



SG Santhosh Govindasamy Syncfusion Team August 1, 2024 11:41 AM UTC

Hi Sabian Sirius,

Thank you for your reply. We look forward to your response on changing the data source.


Based on your further update, we noticed that the TotalSummaryRow content is clipped when there is no data, did you point this clipping issue. To proceed further, could you please share the details of how you added the TotalSummaryRow in the DataGrid control and the settings for the table summary row? Providing a code snippet would be helpful for us to understand and assist you better.

Thank you for your cooperation.

Regards,
Santhosh.G


Loader.
Up arrow icon