title: No more post back after file download in sharepoint
body: <p>I tried to download a file from sharepoint.
  But after I download this file, I can't click on other buttons.
  What is wrong with my coding?</p>
  
  <p><strong>This is my first way.</strong></p>
  
  <blockquote>
  <pre><code>            Response.AppendHeader("content-disposition", "attachment; filename= " + fileName);
              Response.ContentType = "text/plain";
              Response.WriteFile(Server.MapPath("~/" + fileName));
              Response.End();
  </code></pre>
  </blockquote>
  
  <p><strong>This is my second way</strong></p>
  
  <blockquote>
  <pre><code>            byte[] bytes = System.IO.File.ReadAllBytes("D:\\" + fileName);
  
              Response.ClearContent();
              Response.ClearHeaders();
              Response.AddHeader("Content-Type", "application/octet-stream");
              Response.AddHeader("Content-Length", bytes.Length.ToString());
  
              Response.AddHeader("content-disposition", "attachment; filename= " + fileName);
  
              Response.BinaryWrite(bytes);
              Response.Flush();
              Response.End();
  </code></pre>
  </blockquote>
  
  <p>I even comment Response.End() but still the same result.</p>
  
  <p>Is there any other way I should tried?</p>
  
  <p>Any help would be really appreciated.
  In fact, I posted this question a few days ago, but only one gave me my second way to try but it is still not working.</p>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Here is my GridView under GridView.</p>
  
  <pre><code>           &lt;asp:GridView ID="gvGiro" Width="100%" runat="server" GridLines="Both" AllowPaging="false" CssClass="form-table" ShowHeader="false"
                  AllowSorting="false" AutoGenerateColumns="false" OnRowDataBound="gvGiro_RowDataBound"&gt;
                  &lt;Columns&gt;
                      &lt;asp:TemplateField ItemStyle-Width="20%" ItemStyle-HorizontalAlign="Center"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:Label ID="lblValueDate" Text='&lt;%# getDate(Eval("ValueDate")) %&gt;' runat="server" /&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                      &lt;asp:TemplateField&gt;
                          &lt;ItemTemplate&gt;
  
                              &lt;asp:GridView ID="gvDetail" runat="server" AllowPaging="false" AllowSorting="false" 
                                  CssClass="list-table border" HeaderStyle-CssClass="header" AutoGenerateColumns="false"&gt;
                                  &lt;Columns&gt;
                                      &lt;asp:TemplateField HeaderText="Sequence Number" ItemStyle-HorizontalAlign="Left"
                                          ItemStyle-Width="30%" &gt;
                                          &lt;ItemTemplate&gt;
                                              &lt;%#((DataRowView)Container.DataItem)["MessageSeqNbr"] %&gt;
                                          &lt;/ItemTemplate&gt;
                                      &lt;/asp:TemplateField&gt;
                                      &lt;asp:TemplateField HeaderText="Total Number of Debit Transaction" ItemStyle-HorizontalAlign="Left"
                                          HeaderStyle-HorizontalAlign="Center"&gt;
                                          &lt;ItemTemplate&gt;
                                              &lt;%#((DataRowView)Container.DataItem)["TotalDebitNbr"] %&gt;
                                          &lt;/ItemTemplate&gt;
                                      &lt;/asp:TemplateField&gt;
                                      &lt;asp:TemplateField HeaderText="Status" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="25%"
                                          HeaderStyle-HorizontalAlign="Center"&gt;
                                          &lt;ItemTemplate&gt;
                                              &lt;%#((DataRowView)Container.DataItem)["CodeDesc"] %&gt;
                                              &lt;asp:HiddenField ID="hidCode" runat="server" Value='&lt;%#((DataRowView)Container.DataItem)["Code"] %&gt;' /&gt;
                                          &lt;/ItemTemplate&gt;
                                      &lt;/asp:TemplateField&gt;
                                      &lt;asp:TemplateField HeaderText="Action" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="10%"
                                          HeaderStyle-HorizontalAlign="Center"&gt;
                                          &lt;ItemTemplate&gt;
                                          &lt;asp:Button ID="btnDownload" runat="server" CssClass="button submit" Text="Download" 
                                  CommandName="download" OnCommand="onCmd" CommandArgument='&lt;%#Eval("Id") %&gt;' Width="80px"/&gt;
                                          &lt;asp:Button ID="btnUnbatch" runat="server" CssClass="button generic" Text="Un-Batch"
                                  CommandName="unbatch" OnCommand="onCmd" CommandArgument='&lt;%#Eval("Id") %&gt;' Width="80px"/&gt;
                                          &lt;/ItemTemplate&gt;
                                      &lt;/asp:TemplateField&gt;
                                  &lt;/Columns&gt;
                              &lt;/asp:GridView&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                  &lt;/Columns&gt;
              &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Here is my cs file</p>
  
  <pre><code>    protected void gvGiro_RowDataBound(object sender, GridViewRowEventArgs e)
      {
          GridView gr;
          if (e.Row.RowType == DataControlRowType.DataRow)
          {
              gr = (GridView) e.Row.FindControl("gvDetail");
              using (class2 ct2= new Class2())
              {
                  Label lblValueDate = (Label)e.Row.FindControl("lblValueDate");
                  DateTime dt= DateTime.MinValue;
                  DataSet ds= ct2.GetData(dt);
                  gr.DataSource = ds; 
                  gr.DataBind();
  
              }
  
          }
      }
  
  
  protected void onCmd(object sender, CommandEventArgs e)
      {
          string id;
          switch (e.CommandName)
          {
              case "unbatch":
                  id= e.CommandArgument.ToString();
                  Unbatch(id);
                  break;
              case"download":
                  id= e.CommandArgument.ToString();
                  Download(id);
                  break;
              default:
                  break;
          }
      }
  
      protected void Download(string id)
      {
          // to do - substitute all hard-code guid
          Guid batchId = new Guid(id);
          string fileName = "";
          Class1 ct = new Class1();
  
  
          {
              if (!ct.FileExists(batchId , ref fileName))
              {
                  byte[] bytes = System.IO.File.ReadAllBytes("D:\\" + fileName);
              Response.ClearContent();
              Response.ClearHeaders();
              Response.AddHeader("Content-Type", "application/octet-stream");
              Response.AddHeader("Content-Length", bytes.Length.ToString());
              Response.AddHeader("content-disposition", "attachment; filename= " + fileName);
              Response.BinaryWrite(bytes);
              Response.Flush();
              Response.End();
              }
  </code></pre>