This is a migrated thread and some comments may be shown as answers.

Refresh RadGridView after dataset has changed.

3 Answers 2075 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Eusebio
Top achievements
Rank 1
Veteran
Eusebio asked on 30 Dec 2020, 09:41 AM

Hello,
I want to remove a row from the grid, I remove it from the DataSet but it doesn't refresh in the grid. How do I make the grid update after deleting a row in the DataSet?
Is there a better way to do it? Maybe deleting the row in the grid?
What is the best strategy to do it?
I only want to do this in memory, since the update in the database is done with ADO and SQL statements.

Best regards.

 

My code:

            DataRow[] drr = dsHojaCalculo.Tables[0].Select("key_guid = '"+ esteAEliminarGuid+  "' ");
            foreach (var fila in drr)
            {
                fila.Delete();
                dsHojaCalculo.Tables[0].AcceptChanges();
            }

            gridHc.DataSource = null;
            gridHc.DataSource = dsHojaCalculo.Tables[0];



 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 30 Dec 2020, 10:51 AM

Hello, Eusebio,

Note, RadGridView is capable of fetching bindable properties and data. However, one important issue must be noted: during the data binding process, the grid extracts the data from the data source, but for any later changes in the data source, RadGridView should be notified. When you have RadGridView bound to a data set, it is not necessary to delete rows from the database and then to synchronize the grid. You may delete rows directly using the RadGridView. Then, you should use the UserDeletingRow event to update the database accordingly. I would highly recommend you to carefully read the following article where different examples are shown: https://docs.telerik.com/devtools/winforms/controls/gridview/populating-with-data/updating-the-database-with-ado.net. I believe it would be of great help to you.

The following threads might be helpful as well:
https://www.telerik.com/forums/delete-a-record-in-the-grid-and-database 
https://www.telerik.com/forums/refresh-still-not-working 

I hope this information helps. Let me know if you need further assistance.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Eusebio
Top achievements
Rank 1
Veteran
answered on 30 Dec 2020, 02:03 PM

Thank Nadya,

I did this way:

            gridHc.MasterTemplate.MasterViewInfo.CurrentRow.Delete();
            dsHojaCalculo.Tables[0].AcceptChanges();

 

Thanks,

 

 

0
Nadya | Tech Support Engineer
Telerik team
answered on 30 Dec 2020, 02:14 PM

Hello, Eusebio,

I am really glad that the suggested information helps and you managed to solve the problem that you have. 

Should you have other questions do not hesitate to contact me.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
Eusebio
Top achievements
Rank 1
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Eusebio
Top achievements
Rank 1
Veteran
Share this question
or