1.后台如何创建 GridView
我是这样写的
GridView gv=new GridView();//创建GridView
gv.AutoGenerateColumns = false;
DB.GridV(sqltr,gv);//绑定数据
但是在前台显示不出数据??这样写不行么?
2存储过程导出的excel,如何实现下载功能?存储过程导出的excel 好像只能保存到某个盘符下```不能保存在项目中的文件中··也就是不能使用相对路径!我的方法是保存到电脑某个盘符中的某个文件中,然后提供下载路径,结果下载IE提示没有权限?应该要怎么做哦??? 最好能保存相对路径··
我是这样写的
GridView gv=new GridView();//创建GridView
gv.AutoGenerateColumns = false;
DB.GridV(sqltr,gv);//绑定数据
但是在前台显示不出数据??这样写不行么?
2存储过程导出的excel,如何实现下载功能?存储过程导出的excel 好像只能保存到某个盘符下```不能保存在项目中的文件中··也就是不能使用相对路径!我的方法是保存到电脑某个盘符中的某个文件中,然后提供下载路径,结果下载IE提示没有权限?应该要怎么做哦??? 最好能保存相对路径··
{
var file = new FileInfo(path);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("content-disposition", "attachment;filename=" + HttpUtility.UrlEncode(defaultName) + file.Extension);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = Encoding.Default;
Response.WriteFile(file.FullName);
Response.Flush();
Response.End();
}
至于第一个问题,你可以在页面上放一个panel,在后台调用它的panel.Controls.Add(gv);
string filePath = Server.MapPath("");//路径 FileInfo fileInfo = new FileInfo(filePath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile(fileInfo.FullName);
Response.Flush();
Response.End();