gridview内实现文件下载
实现起来有点迷惑性,用了几种方法,最后用a实现。
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
SelectCommand="SELECT * FROM [files]"></asp:SqlDataSource>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" />
<asp:BoundField DataField="upload_file" HeaderText="upload_file"
SortExpression="upload_file" />
<asp:BoundField DataField="file_name" HeaderText="file_name"
ortExpression="file_name" />
<asp:TemplateField><ItemTemplate>
<a href='<%#DataBinder.Eval(Container.DataItem,"file_name")%>' target="_blank">下载</a>
</Itemtemplate></asp:TemplateField>
</Columns>
</asp:GridView>

</form>
</body>
</html>
实现起来有点迷惑性,用了几种方法,最后用a实现。



"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">









ConnectionString="<%$ ConnectionStrings:testConnectionString %>"




DataSourceID="SqlDataSource1">



SortExpression="upload_file" />

ortExpression="file_name" />



















