In gridview There is an image button to download file. I have used the gridview with updatepanel.If I removed Updatepanel the download option will work fine.But i have to use Updatepanel in this.How can Isolve this?
<asp:UpdatePanel ID="UpdatePanel2" runat="server" >
<ContentTemplate>
<asp:GridView ID="GridImport" runat="server" AutoGenerateColumns="false" Width="99%" Height="50%"
AllowPaging="true" GridLines="None" Style="padding: 15px; text-align: left; overflow: scroll;
font-family: Arial; font-size: 11pt;" ShowHeaderWhenEmpty="true" PageSize="5"
CssClass="Grid_LE" HeaderStyle-CssClass="Grid_Head" EmptyDataText = "No files Imported" OnPageIndexChanging="GridImport_PageIndexChanging">
<Columns>
<asp:BoundField DataField="Text" HeaderText="File Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="lnkDownload" runat="server" CommandArgument='<%# Eval("Value") %>' Style="width: 20px; height: 20px;" ImageUrl="~/Images/download.png" OnClick = "DownloadFile" /> <%--CommandName="Upload" OnClick="DownloadFile"--%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="lnkDelete" runat="server" CommandArgument='<%# Eval("Value") %>' Style="width: 20px; height: 20px;" ImageUrl="~/Images/cancel.png" OnClick="DeleteFile" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
.cs
protected void DownloadFile(object sender, EventArgs e)
{
string filePath = (sender as ImageButton).CommandArgument;
Response.ContentType = ContentType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(filePath));
Response.WriteFile(filePath);
Response.End();
}
protected void DeleteFile(object sender, EventArgs e)
{
string filePath = (sender as ImageButton).CommandArgument;
File.Delete(filePath);
ExprotFileList();
ClientScript.RegisterStartupScript(GetType(), "Val", "ShowExpPopup();", true);
}