请阅读我的问题并使用C#进行整理 [英] Please read my problem and sort out in c#
本文介绍了请阅读我的问题并使用C#进行整理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个下载链接按钮.关于它,我执行PDF文件的下载.其完美执行下载.但是如果Gridview中具有相同工作的linkbutton无法执行下载.
您能告诉我该问题的原因和解决方法吗?
I have a download link button. on it i performing downloading of pdf file. its perfectly perform downloading. but if a linkbutton with in Gridview with same work not performing downloading.
Can u tell me why and solution of that problem.
try {
string contentType = "";
//Get the physical path to the file.
string invoice = "~/Invoice/" + DropDownList1.SelectedItem.ToString() + ".pdf";
string FilePath = HttpContext.Current.Server.MapPath(invoice);
string fileExt = Path.GetExtension(invoice).Split('.')[1].ToLower();
if (fileExt == "pdf")
{
//Set the appropriate ContentType.
contentType = "Application/pdf";
}
//Set the appropriate ContentType.
Response.ContentType = contentType;
Response.AppendHeader("content-disposition", "attachment; filename=" + (new FileInfo(invoice)).Name);
//Write the file directly to the HTTP content output stream.
Response.WriteFile(FilePath);
Response.End();
}
catch
{
//To Do
}
提前感谢
Thanx in advance
推荐答案
此问题是因为ypu在页面加载时绑定数据,因此必须使用Page属性isPostback而不是绑定数据. ..在网格视图中..
this problem is because of ypu are binding data at page load and for that you have to use a Page property isPostback and not to bind data....in grid view..
这篇关于请阅读我的问题并使用C#进行整理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文