I have a dropdown called company and a button called export to excel and a gridview, also I have an update panel for both controls but when I export to excel dropdown won't work anymore, even if a want to export 2times I cannot without refreshing the page.

My export code:

   protected void Button1_Click(object sender, EventArgs e)

      // HttpContext.Current.Response.Clear();
           "content-disposition", string.Format("attachment; filename={0}", "Kontratat-" + DateTime.Now.ToShortDateString() + ".xls"));
       HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";

       StringWriter sw = new StringWriter();
       HtmlTextWriter hw = new HtmlTextWriter(sw);

       HtmlForm frm = new HtmlForm();
       hw.WriteLine("<center><b><u><font size='5'>Kontratat</font></u></b></center>");//will be displayed in excel as a heading.


and my aspx code

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
   <asp:PostBackTrigger ControlID="Button1" />
    <asp:GridView ID="GridView1" runat="server" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="4" CellSpacing="2" ForeColor="Black">

help me please

2 Answers 2


Because you have called the Response.End(), which ends the page execution, the body onload event would never be fired. The problem is sharepoint catches form submits and downloads so you cannot double click a button.

I had same issue, adding below script on aspx page helped me to resolve it

<script type='text/javascript'>
    _spOriginalFormAction = document.forms[0].action;
    _spSuppressFormOnSubmitWrapper = true;

You can find reference here:


Refreshing page or making it to respond after downloading the file. All happening in Webpart


It is SharePoint which displays your value as a DropDown/Select. The Field value in the SQL database is stored as a String (with only the selected value).

When you export to Excel it exports values, not SharePoint functionality

  • thanks now I am clear I appreciate your help so much @danny Jul 11, 2016 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.