The gridview is wrapped up by updatepanel, but the gridview has a download imagebutton. If it is refreshed locally, the file cannot be downloaded. Code Register the Download button in updatepanel. The whole page is PostBack every time you click it. For ( Int I = 0 ; I < This . Gridviewsopdocument. Rows. Count; I ++ )
{
Imagebutton imagebuttondownload = (Imagebutton) This . Gridviewsopdocument. Rows [I]. findcontrol ( " Imagebuttondownload " );
If (Imagebuttondownload ! = Null )
{
(Scriptmanager) (vpjquerymaster) This . Master). findcontrol ( " Scriptmanager1 " ). Registerpostbackcontrol (imagebuttondownload );
}
}
Download Method: Public Void Filedownload ( String Filepath, String Filename, String Systemfilename)
{
Fileinfo downloadfile
= New Fileinfo ( This . Applicationphysicalpath + Filepath + " \\ " + Systemfilename );
If (Downloadfile. exists)
{
Response. Clear ();
Response. clearheaders ();
Response. Buffer = False ;
Response. contenttype = " Application/octet-stream " ;
Response. appendheader ( " Content-Disposition " , " Attachment; filename = "
+ Httputility. urldecode (filename, system. Text. encoding. utf8 ));
Response. appendheader ( " Content-Length " , Downloadfile. length. tostring ());
Response. writefile (downloadfile. fullname );
Response. Flush ();
Response. End ();
}
Else
{
Showajaxmessage ( " Msg_public_download_file_does_not_exist " );
}
}