As I understand, problem is through window1, you are updating datagrid of mainwindow; and after closing window1 and opening it again your datagrid is got cleared.
As it is correct, so it is happen because of
DataTable dt = new DataTable();
dt.Columns.Add("Name");
dt.Columns.Add("ID");
DataRow dr = dt.NewRow();
m.dataGrid1.ItemsSource = dt.DefaultView;
in this line you are creating new datatable and adding as itemsource to datagrid.
So solution is, send existing itemsource as datatable and update it in window1 and it will reflect.