Search code examples
c#mysqlwpfado.netwpfdatagrid

How to refresh datagrid in WPF


My source is in a MySQL database, I've made an update command and now I need to refresh my DataGrid.

MySqlCommand cmd = new MySqlCommand(
  "update request set status = " + StatusRequest(value) + 
  " where id = " + rowView[0].ToString() + "", conn);
MySqlDataReader myReader = cmd.ExecuteReader();

How do I refresh my DataGrid?


Solution

  • Reload the datasource of your grid after the update

    myGrid.ItemsSource = null;
    myGrid.ItemsSource = myDataSource;