asp.net导出成EXCEL
以下是导出的方法:
public static void ToExcel(System.Web.UI.Control ctl)
{
//HttpContext.Current.Response.Charset ="GB2312";
HttpContext.Current.Response.Charset = "GBK";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=memory.xls");
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GBK");
HttpContext.Current.Response.ContentType = "application/ms-excel";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
ctl.Page.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
在其它方法中调用:ToExcel(gridview1);
相关文档:
<%
set conn= server.createobject("ADODB.connection")
conn.open "driver={sybase driver 10};"
"srvr=SYBASE;"
"UID=sa;"
"pwd=sybase;"
sql="select no from tab_st ......
DateTime dt = DateTime.Now;
// Label1.Text = dt.ToString();//2005-11-5 13:21:25
// Label2.Text = dt.ToFileTime().ToString();//127756416859912816
// Label3.Text = dt.ToFileTimeUtc().ToString();//127756704859912816
// Label4.Text = dt.ToLocalTime().ToString();//2005-11-5 21:21:25
// Label5.Text = ......
创建和配置ASP.NET Session状态数据库
在基于NLB(网络负载平衡)环境下的ASP.NET Web应用程序开发,我们需要将Session存储在数据库中供多个Web应用程序调用,以下为配置方法及注意事项。
1.创建用于存储ASP.NET Session的数据库(远程、本地皆可,使用数据库用户身份认证)
在Windows\Microsoft.NET\Framework/V2.0.507 ......
static void Main(string[] args)
{
string connstr = "Data Source=***;user=system;password=***;";
OracleConnection conn = new OracleConnection(connstr);
conn.Open();
string orclstr="insert into SYS.A_MODULE values('03','查看生产任务','查看生产任务进度')";
  ......
1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open(’*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"’)</script>")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.为按钮添加对话框
Button1 ......