日期:2014-05-17 浏览次数:20656 次
绑定页面展示的分页代码:
private void BindListShow()
{
AspNetPager1.PageSize = 10;//初始化分页中每页显示的信息条数
AspNetPager1.RecordCount = Convert.ToInt32(BLL.MileageReportManage.getMileageCount(DropDown_year.SelectedValue.ToString(), AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, "").ToString());
DataList1.DataSource= mileageReportManage.getMileageReport(DropDown_year.SelectedValue.ToString(), AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, "").Tables[0].DefaultView;
DataList1.DataBind();
}
导出excel的代码:
protected void ibtnDR_Click(object sender, ImageClickEventArgs e)
{
Response.Clear();//清空缓存
Response.Buffer = true;//启用缓存
Response.Charset = "GB2312";//设置编码格式
Response.AppendHeader("Content-Disposition","attachment;filename=filename.xls");//设置输出文件格式
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");//设置输出流为简体中文
Response.ContentType = "application/ms-Excel";//设置输出文件类型为Excel文件
this.EnableViewState = false;
System.Globalization.CultureInfo mycitrad = new System.Globalization.CultureInfo("ZH-CN",true);
System.IO.StringWriter swriter = new System.IO.StringWriter(mycitrad);
System.Web.UI.HtmlTextWriter htmltextw = new System.Web.UI.HtmlTextWriter(swriter);
this.DataList1.RenderControl(htmltextw);//读取DataList1中的数据
Response.Write(swriter.ToString());//输出到stringwriter
Response.End();
}
string query&nbs