views:

32

answers:

1

I have a gridview that is supposed to refresh using

        gridView.DataSource = null;
        gridView.DataBind();

before binding it to the updated datasource (which is a DataTable).

and then

gridView.DataSource = newDataTable;
gridView.DataBind();

The problem is that it won't clear and from time to time I get a table on top of another table (the one on top is the updated one, the bottom one is the data before the 2nd DataBind).

Appreciate your help!

A: 

I usually hook up to the data-source updated or inserted event and then call the DataBind method directly after the Insert and Update has executed.

You can also try adding this before you reload the grid, although the databind should refresh it:

gridView.Dispose();

James Campbell