各位大侠...请帮忙看一下如下代码:..是一下实现下载的功能..所要下载的东西是存入在数据库中的...在如下代码中绑定DataGrid:
string conn = ConfigurationSettings.AppSettings["conn"];
string select = ConfigurationSettings.AppSettings["select"];
SqlConnection objSqlCon = new SqlConnection(conn);
SqlCommand command = new SqlCommand(select,objSqlCon);
objSqlCon.Open();
FileList.DataSource = command.ExecuteReader();
FileList.DataBind();
objSqlCon.Close();
在HTML代码页里做了一个超链的绑定列..
<asp:TemplateColumn HeaderText="查看">
<ItemTemplate>
<b><a href="ShowFile.aspx?ID=1">下载文件</a> </b>
</ItemTemplate>
</asp:TemplateColumn>
string conn = ConfigurationSettings.AppSettings["conn"];
string select = ConfigurationSettings.AppSettings["select"];
SqlConnection objSqlCon = new SqlConnection(conn);
SqlCommand command = new SqlCommand(select,objSqlCon);
objSqlCon.Open();
FileList.DataSource = command.ExecuteReader();
FileList.DataBind();
objSqlCon.Close();
在HTML代码页里做了一个超链的绑定列..
<asp:TemplateColumn HeaderText="查看">
<ItemTemplate>
<b><a href="ShowFile.aspx?ID=1">下载文件</a> </b>
</ItemTemplate>
</asp:TemplateColumn>
解决方案 »
- 网站如何请求一个应用程序?或者大家给看看这个需求怎么做?
- 求助在简单的仓库管理系统中,如何判断当前的表单数入库还是出库类型的
- 超级白痴的问题CS文件为什么只能掉用自己类中的static方法
- 在DataGrid的绑定代码中实现超级连接并传输多个参数。
- 大家帮我看看
- 請教.net高手!不是高手不要來.
- 用户注册控件或登录控件与数据库连接的问题?
- 对VS.Net中的SQL Server连接,有没有办法既方便开发,又方便在发布后更改连接字符串?
- 求在DATALIST中如何给dropdownlist加上selectindexchange方法
- 如何在客户端保存Excel?
- 菜单控件
- 大家帮我看看这个ASP网页用ASP.NET怎么实现
string sql="SELECT * FROM TestFiles WHERE ID = '" + Request.QueryString["ID"] + "'";
string conn = ConfigurationSettings.AppSettings["conn"];
SqlConnection objSqlCon = new SqlConnection(conn);
SqlCommand objSqlCom = new SqlCommand(sql,objSqlCon);
try
{
objSqlCon.Open();
SqlDataReader objRead = objSqlCom.ExecuteReader();
if(objRead.Read())
{
Response.Clear();
Response.AddHeader("Content-Type",objRead["FileType"].ToString());
Response.BinaryWrite((byte[])objRead["MyFile"]);
Response.End();
}
objRead.Close();
}
catch(SqlException se)
{
Response.Write(se.Message);
}
finally
{
objSqlCon.Close();
}请问:这样做有问题吗?为什么我单击下载以后..不能