/// <summary> /// Exporting all the records by rebinding the gridview and re-setting the page index /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void lnkExport_Click(object sender, EventArgs e) { if (ExcelColumns != null) { foreach (DataControlField field in ExcelColumns) { this.Columns.Add(field); } } this.AllowMultiColumnSorting = false; this.AllowPaging = false; this.AllowSorting = false; this.ShowFooter = false; this.EnableViewState = false; this.PageIndex = 0; this.PageSize = this.RecordsCount; this.DataSourceID = this.DataSourceID; this.DataBind(); GridViewExcelExporter exp = new GridViewExcelExporter(); exp.BeforeFormat += new ExcelFormatEventHandler(exp_BeforeFormat); exp.AfterFormat += new ExcelFormatEventHandler(exp_AfterFormat); exp.Export(_excelExportFileName, this.Page, this); }