读书人

Gridview的模板列中怎么点击HyperLink

发布时间: 2011-12-23 23:32:01 作者: rapoo

Gridview的模板列中如何点击HyperLink或Linkbutton后打开文件,并且触发后台事件
我的gridview中有一列是模板列,在rowdatabound事件中动态添加数量不定的文件链接,文件类型不定,当点击其中任一链接后,弹出下载对话框,行为和HyperLink类似,同时要触发gridview的rowcommand事件,统计点击次数,行为和LinkButton类似,不知如何处理

[解决办法]
出文件下框,可用此方法:
private void FileDownload(string FullFileName)
{
FileInfo DownloadFile = new FileInfo(FullFileName);
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "application/octet-stream ";
Response.AppendHeader( "Content-Disposition ", "attachment;filename= " + HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
Response.AppendHeader( "Content-Length ", DownloadFile.Length.ToString());
Response.WriteFile(DownloadFile.FullName);
Response.Flush();
Response.End();
}
[解决办法]
关注 。。。。。。。。
[解决办法]
在rowcommand事件中先处理计数,然后向前台写个脚本.window.open( "文件地址 ", "_new ", " ");

读书人网 >asp.net

热点推荐