Telerik gridview : How to refresh grid view after Database change

25,818

Solution 1

Well, I found the answer myself. Although it only works on dataGridView and doesn't work on dataListView.
To delete a record and commit changes to database :

radGridView1.CurrentRow.Delete();
this.yourTableAdapter.Update(yourDataSet);

On the other hand, if you have added new records and you want to reform the list :

this.yourTableAdapter.Fill(yourDataSet.yourTabel);

If you know how to do the same with dataListView, I'll be glad to hear.

Solution 2

When datasource get changes, to refresh datagrid use following code :

this.radGridViewName.MasterTemplate.Refresh(null); 

this line solved my problem :-)

Solution 3

You can use simple soultion to refresh data in grid:

MyGrid.DataSource = null;
MyGrid.DataSource = updatedData;

Solution 4

Here is a tutorial, explaining in a step by step manner how to bind the grid. Once it is bound, changes introduced to the underlying source will be automatically reflected and changed in RadGridView will be updated in the DataTable after you Update the TableAdapter.

Share:
25,818
Rsh
Author by

Rsh

I mostly spend time in the terminal, passing functions around and trying to make the tests pass. Currently, I mostly work with perl and C++ to make sure the stream of numbers in the system is as fast and as smooth as possible.

Updated on July 05, 2022

Comments

  • Rsh
    Rsh almost 2 years

    I'm using radgridview in C# winform application to show data from database. I'm also altering database through ADO.Net. The problem is after I change the database, for example by deleting a row or adding a new row, changes do not appear in gridview.
    I also want to mention that I have bound database to gridview through smart tags and when I tried to create a new dataset and assign it to radgridview1.datasource I got tons of errors.
    Any suggestion on how can force radgridview to reload it's datasource ?