问题描述
下载链接的网格视图代码:
My Grid view code for download link buttion:
<asp:TemplateField HeaderText="Download">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"
Text='<%# Eval("Files") %>' CommandArgument='<%# Eval("Files") %>'
onclick="LinkButton1_Click" ></asp:LinkButton>
</ItemTemplate>
我用文件夹存储文件.. ......
I am using folder to store the file........
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "filename=" + e.CommandArgument);
<big></big><big>Response.TransmitFile(Server.MapPath("~/Files/") + e.CommandArgument);</big>
Response.End();
}
使用网格视图分页时在文件夹中找不到路径.....
请帮帮我,我正在做项目.....
找不到文件'C:\ Users \THAMILARASAN \Desktop \Back up2 \ Virtual Classroom \ Virtual Classroom \Files \\\'。
描述:在此期间发生了未处理的异常执行当前的Web请求。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.IO.FileNotFoundException:找不到文件'C:\Users\THAMILARASAN \Desktop\Back up2 \ Virtual Classroom \\ \\ Virtual Classroom \Files \'''。
来源错误:
第27行:Response.ContentType =application / octet-stream;
第28行:Response.AppendHeader(Content-Disposition,filename =+ e.CommandArgument);
第29行:Response.TransmitFile(Server.MapPath(〜/ Files /)+ e.CommandArgument);
第30行:Response.End();
第31行:}
When using a grid view paging cannot find the path in the folder.....
please help me i am doing project.....
Could not find file 'C:\Users\THAMILARASAN\Desktop\Back up2\Virtual Classroom\Virtual Classroom\Files\2'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not find file 'C:\Users\THAMILARASAN\Desktop\Back up2\Virtual Classroom\Virtual Classroom\Files\2'.
Source Error:
Line 27: Response.ContentType = "application/octet-stream";
Line 28: Response.AppendHeader("Content-Disposition", "filename=" + e.CommandArgument);
Line 29: Response.TransmitFile(Server.MapPath("~/Files/") + e.CommandArgument);
Line 30: Response.End();
Line 31: }
推荐答案
<asp:TemplateField HeaderText="Download">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"
Text='<%# Eval("Files") %>'
CommandArgument='<%# Eval("Files") %>'
CommandName="DownloadFiles"
onclick="LinkButton1_Click"
/>
</ItemTemplate>
</asp:TemplateField>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "DownloadFiles")
{
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "filename=" + e.CommandArgument);
Response.TransmitFile(Server.MapPath("~/Files/") + e.CommandArgument);
Response.End();
}
}
这篇关于使用网格视图分页时找不到路径.......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!