protected void GridWeb1_SaveCommand(object sender, EventArgs e)
{
// Generates a temporary file name.
string filename = Session.SessionID + "_out.xls";
string path = (this.Master as Site).GetDataDir() + "\\Worksheets\\";
// Saves to the file.
this.GridWeb1.SaveToExcelFile(path + filename);
// Sents the file to browser.
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("content-disposition", "attachment; filename=" + filename);
Response.WriteFile(path + filename);
Response.End();
}