温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:Asp.net房产中介管理系统源码及常用文档
当前文件路径:HouseManage/ContractManage/QueryLeasePrint.aspx.cs

1//文件名:QueryLeasePrint.aspx.cs 2
using System; 3
using System.Data; 4
using System.Configuration; 5
using System.Collections; 6
using System.Web; 7
using System.Web.Security; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.WebControls.WebParts; 11
using System.Web.UI.HtmlControls; 12
13
using System.Data.SqlClient; 14
public partial class ContractManage_QueryLeasePrint : System.Web.UI.Page 15
{ 16
private ContractManage_QueryLeaseForm MyPrintForm; 17
protected void Page_Load(object sender, EventArgs e) 18
{//将查询结果输出到Excel文件中 19
MyPrintForm = (ContractManage_QueryLeaseForm)Context.Handler; 20
string MySQL = MyPrintForm.MyPrintSQL; 21
this.Label1.Text = Session["MyCompanyName"].ToString() + "租房信息查询结果表"; 22
this.Label2.Text = MyPrintForm.MyPrintDate; 23
string MyConnectionString = ConfigurationManager.ConnectionStrings["MyHouseDBConnectionString"].ConnectionString; ; 24
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnectionString); 25
DataSet MySet = new DataSet(); 26
MyAdapter.Fill(MySet); 27
this.DataGrid1.DataSource = MySet; 28
this.DataGrid1.DataBind(); 29
this.Response.ContentType = "application/vnd.ms-excel"; 30
this.Response.Charset = ""; 31
this.EnableViewState = false; 32
System.IO.StringWriter MyWriter; 33
System.Web.UI.HtmlTextWriter MyWeb; 34
MyWriter = new System.IO.StringWriter(); 35
MyWeb = new System.Web.UI.HtmlTextWriter(MyWriter); 36
this.DataGrid1.RenderControl(MyWeb); 37
Response.Write(MyWriter.ToString()); 38
} 39
} 40





}
}