gridview内实现文件下载
实现起来有点迷惑性,用了几种方法,最后用a实现。

<%...@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>无标题页</title>
</head>
<body>
<formid="form1"runat="server">
<div>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"
ConnectionString="<%$ConnectionStrings:testConnectionString%>"
SelectCommand="SELECT*FROM[files]"></asp:SqlDataSource>

</div>
<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundFieldDataField="id"HeaderText="id"SortExpression="id"/>
<asp:BoundFieldDataField="upload_file"HeaderText="upload_file"
SortExpression="upload_file"/>
<asp:BoundFieldDataField="file_name"HeaderText="file_name"
ortExpression="file_name"/>




<asp:TemplateField><ItemTemplate>
<ahref='<%#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"/>



















