hello every one;
what is wrong with the following code while i am clicking on the download button it is not giving me erro neither it is not downloading
why?
<div class="col-sm-6">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="قباله">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("QBName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="داونلود فایل"
CommandName="Download" CommandArgument='<%# Eval("filePath") %>'
OnCommand="Button1_Command" CausesValidation="false" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:GridView ID="GridView2" runat="server">
</asp:GridView>
</div>
</div>
protected void Button1_Command(object sender, CommandEventArgs e)
{
string filePath = e.CommandArgument.ToString();
if(File.Exists(filePath))
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("content-disposition", "filename="
+ filePath);
Response.WriteFile(filePath);
Response.Flush();
Response.End();
}
}