F
fix
Hi,
I am using the DataGrid to display a DataTable. I need to update the
grid every time I update the table in the database. Here is my code to
do that. The problem is that every time the code below runs, the old
rows stays and the new rows are added. Is there any way that I can clear
the grid before refreshing? I tried setting the datasource to null, but
that doesn't help.
Thanks.
fix.
=========================
string SelectSQL = "SELECT * FROM Fruits";
SqlCeCommand SelectCmd = new SqlCeCommand(SelectSQL, Connection);
SqlCeDataAdapter da = new SqlCeDataAdapter(SelectCmd);
try
{
da.Fill(ds);
}
catch (SqlCeException ex)
{
DisplaySQLCEErrors(ex);
}
dt = ds.Tables[0];
GridFruits.DataSource = dt;
GridFruits.Refresh();
I am using the DataGrid to display a DataTable. I need to update the
grid every time I update the table in the database. Here is my code to
do that. The problem is that every time the code below runs, the old
rows stays and the new rows are added. Is there any way that I can clear
the grid before refreshing? I tried setting the datasource to null, but
that doesn't help.
Thanks.
fix.
=========================
string SelectSQL = "SELECT * FROM Fruits";
SqlCeCommand SelectCmd = new SqlCeCommand(SelectSQL, Connection);
SqlCeDataAdapter da = new SqlCeDataAdapter(SelectCmd);
try
{
da.Fill(ds);
}
catch (SqlCeException ex)
{
DisplaySQLCEErrors(ex);
}
dt = ds.Tables[0];
GridFruits.DataSource = dt;
GridFruits.Refresh();