After downloading an excel with the grid data all my buttons on the page lose the functionality (search button to refresh the grid with other parameters and download a new excel with other data, eg dates).
I have tried to force him to refresh the page after downloading, both by server and by javascript, and he does not pay any attention to me (he is a rebel).
I have been told that it could be a devexpress bug ... Any ideas or alternatives?
ascx
<asp:Panel ID="DivContactosButtons" runat="server" CssClass="smc-gridButtons">
<dx:ASPxButton ID="btnXlsExport" runat="server" Text="Export to XLS" OnClick="btnXlsExport_Click" CssClass="buttonsGrid">
<ClientSideEvents Click="SMCContactosVisitasAspXGirdViewExportOnClick" />
</dx:ASPxButton>
</asp:Panel>
<dx:ASPxGridViewExporter ID="gridExporter" runat="server"></dx:ASPxGridViewExporter>
ascx.cs
protected void btnXlsExport_Click(object sender, EventArgs e)
{
using (MemoryStream stream = new MemoryStream())
{
this.gridExporter.WriteXls(stream);
WriteToResponse(this.ExcelName, true, "xls", stream);
}
}
protected void WriteToResponse(string fileName, bool saveAsFile, string fileFormat, System.IO.MemoryStream stream)
{
if (string.IsNullOrWhiteSpace(fileName))
{
fileName = "exportedGrid";
}
if (Page == null || Page.Response == null) return;
string disposition = saveAsFile ? "attachment" : "inline";
Page.Response.Clear();
Page.Response.Buffer = false;
Page.Response.AppendHeader("Content-Type", string.Format("application/{0}", fileFormat));
Page.Response.AppendHeader("Content-Transfer-Encoding", "binary");
Page.Response.AppendHeader("Content-Disposition", string.Format("{0}; filename={1}.{2}", disposition, HttpUtility.UrlEncode(fileName).Replace("+", "%20"), fileFormat));
if (stream.Length > 0)
{
Page.Response.BinaryWrite(stream.ToArray());
}
//Page.Response.Redirect(Page.Request.Url.ToString(), true);
}