易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net将页面中gridview中的数据导入excel表中

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
namespace AJAXEnabledWebApplication1
{
public partial class excelOutput : System.Web.UI.Page
{
DBClass db = new DBClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string strsql = "select * from TreeViewTemp where parentID=0";
DataTable dt = db.GetDataTable(strsql);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{

OutPutExcel();
}
//此处要注意,这个重载方法,一定要写,不然会报类型“GridView”的控件“GridView1”必须放在具有 runat=server 的窗体标记内
public override void VerifyRenderingInServerForm(Control control)
{
}
public void OutPutExcel()
{
//定义文档类型、字符编码
Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
//下面这行很重要, attachment 参数表示作为附件下载,您可以改成 online在线打开
//filename=FileFlow.xls 指定输出文件的名称,注意其扩展名和指定文件类型相符,可以为:.doc    .xls    .txt   .htm
Response.AppendHeader("Content-Disposition", "attachment;filename=FileFlow.xls");
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
//Response.ContentType指定文件类型 可以为application/ms-excel、application/ms-word、application/ms-txt、application/ms-html 或其他浏览器可直接支持文档


相关文档:

asp.net中a控件触发b控件服务器端事件

要实现a控件控件触发b控件服务器端事件,需给a控件添加js脚本,以b控件名义提交页面,具体代码:
var theForm = document.forms['form1'];
theForm.__EVENTTARGET.value = "b"; //触发b控件服务器端方法
theForm.__EVENTARGUMENT.value = "a trigger";//传递的参数
theForm.submit();
注意:需要设置页面属性中的 enab ......

Online active users counter in ASP.NET


Online active users counter in ASP.NET
With this tool which is written for ASP.NET, it is possible to count the number of online users, members and guest users in web sites.
Installation
The tool installation is very simple and only takes a few minutes.
Step one - Add Reference:
After downlo ......

Asp.NET常用函数

Ucase(string) 将字符串转换为大写。
Val(string) 将代表数字的字符串转换为数值型态,若字符串中含有非数字的内容则会将其去除后,合并为一数字。
Weekday(date) 取的参数中的日期是一个星期的第几天,星期天为1、星期一为2、星期二为3 依此类推。
WeekDayName(number) 依接收的参数取得星期的名称,可接收的参数为1 到 ......

ASP.NET配置文件Web.config 详细解释

一、认识Web.config文件
 
    Web.config文件是一个XML文本文件,它用来储存 ASP.NET Web 应用程序的配置信息(如最常用的设置ASP.NET Web 应用程序的身份验证方式),它可以出现在应用程序的每一个目录中。当你通过VB.NET新建一个Web应用程序后,默认情况下会在根目录自动创建一个默认的
  Web.co ......

asp.net将sql数据导出excel表格(代sql字段名)

protected void Button1_Click(object sender, EventArgs e)
{
string strsql = "select * from TreeViewTemp where parentID=0";
DataTable dt = db.GetDataTable(strsql);
StringWriter sw = new StringWriter();
//StreamWriter sw = new Strea ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号