DataSet ds = new DataSet(); dgvBill.EndEdit(); ds.WriteXml(@"..\..\Customer_Info\" + lblCustId.Text + ".xml"); dgvBill.DataSource = ds;