我现在用gridview从数据库里取出来了,由于数据太多,用了分页显示,但是把数据导入excel 中却出现了问题?
不分页 的时候没有问题....
该怎么实现?
不分页 的时候没有问题....
该怎么实现?
解决方案 »
- Form表单无法过滤HTML标记 提示有潜在危险
- .net如何设置Session的有效期
- web.config配置httpHandlers报错
- 【求教】HyperLinkField的传值
- Repeater不能显示问题,很急!求大家帮忙
- 怎么对比两表,取出不同的数据?????
- 用asp.net做的oa系统架到公司内网后,经常导致公司服务器的数据库断开连接,这是怎么回事?
- 请问使用.net程序,如何在另一台机器上新建目录呀?
- 基于flash的在线视频交流问题
- 求大神!!!VS2012 aspx页面代码显示灰色
- 现在有一个vb写的ocx,希望在asp.net中使用,如何做呢?
- 在使用传参设置Web.config后,Cuteditor编辑器报错...
代码帖上:private void BindGrid()
{
GridView.DataSource = 数据源;
GridView.DataBind()
} protected void Button1_Click(object sender, ImageClickEventArgs e)
{
GridView.AllowPaging = false; //设置分页为false
GridView.AutoGenerateEditButton = false;
GridView.AutoGenerateDeleteButton = false;
BindGrid1(); //重新载入
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "gb2312";
Response.ContentType = "application/vnd.xls";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
Response.Write(" <meta http-equiv=Content-Type content=\"text/html; charset=GB2312\"> "); System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
GridView.AllowPaging = true; //从新设置分页为true
}
ok/
//清空
this.ExportPrint.DataSource = null;
this.ExportPrint.DataBind();
//查找数据
string sql_SelectAll = " select " + SearchContent + " from " + TableName + " " + WhereString + " " + OrderString + " desc ";
DataSet ds_SelectAll = p.DataSetSearch(strCon,sql_SelectAll);
DataTable dt_SelectAll = JoinData(ds_SelectAll);
if(dt_SelectAll != null && dt_SelectAll.Rows.Count > 0)
{
this.ExportPrint.DataSource = dt_SelectAll;
this.ExportPrint.DataBind();
}
数据源分页的话,只能用另一段sql导数据了
不赞成再隐藏一个datagrid之类的,如果数据量不大的话还好说,数据量大的时候就郁闷了