温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:固定资产管理系统源码
当前文件:
DepreciationManage/DepreciationManage/QueryDepreciationPrint.aspx.cs[1K,2009-6-12 11:38:44],打开代码结构图
DepreciationManage/DepreciationManage/QueryDepreciationPrint.aspx.cs[1K,2009-6-12 11:38:44],打开代码结构图1//文件名:QueryDepreciationPrint.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 DepreciationManage_QueryDepreciationPrint : System.Web.UI.Page 15
{ 16
private DepreciationManage_QueryDepreciationForm MyQueryForm; 17
protected void Page_Load(object sender, EventArgs e) 18
{//将查询结果输出到Excel文件中 19
MyQueryForm = (DepreciationManage_QueryDepreciationForm)Context.Handler; 20
string MySQL = MyQueryForm.MyPrintSQL; 21
this.Label1.Text = MyQueryForm.MyPrintTitle; 22
this.Label2.Text = MyQueryForm.MyPrintDate ; 23
string MyConnectionString = ConfigurationManager.ConnectionStrings["MyAssetsDBConnectionString"].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
//关闭 ViewState 32
this.EnableViewState = false; 33
System.IO.StringWriter MyWriter; 34
System.Web.UI.HtmlTextWriter MyWeb; 35
//将信息写入字符串 36
MyWriter = new System.IO.StringWriter(); 37
//在Web窗体页上写出一系列连续的HTML特定字符和文本 38
MyWeb = new System.Web.UI.HtmlTextWriter(MyWriter); 39
//将DataGrid中的内容输出到HtmlTextWriter对象中 40
this.DataGrid1.RenderControl(MyWeb); 41
//把HTML写回浏览器 42
Response.Write(MyWriter.ToString()); 43
} 44
} 45






}
}