- 浏览: 106007 次
- 性别:
- 来自: 长沙
最新评论
-
吉米家:
水晶报表的话,登录的确不是很好用,相比之下,帆软报表更加实用一 ...
水晶报表读取Web.config 登陆设置 -
wyqdl:
请问mysql-2.7.3-mswin32.gem这个文件从哪 ...
解决Rails2.33 与Mysql连接问题 -
wohaizai007:
你好,我是ruby初学者,你的资料没有下下来,请问怎么联系你, ...
学习ruby on rails的视频教程和电子书下载 -
allwefantasy:
zhangbo520 写道没想到出现No definition ...
Ruby on Rails 安装札记 -
zhangbo520:
没想到出现No definition for dummy_du ...
Ruby on Rails 安装札记
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BLL;
using Aspose.Cells;
using DBUtility;
using System.IO;
using System.Data.OleDb;
using Model;
using System.Collections.Generic;
using SQLServerDAL;
using System.Text;
public partial class query_query : System.Web.UI.Page
{
public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.GridView1.DataSource = PropertyBLL.GetPropertyInfo();
this.GridView1.DataBind();
}
}
protected void bt_query_Click(object sender, EventArgs e)
{
string column= this.DropDownList1.SelectedValue;
string condition= this.DropDownList2.SelectedValue;
string txtValue = this.TextBox1.Text.ToString().Trim();
string sqlwhere = "";
if (condition == "")
{
this.GridView1.DataSource = PropertyBLL.GetPropertyInfo();
this.GridView1.DataBind();
}
switch (condition)
{
case "in":
sqlwhere = " where " + column + " in ('" + txtValue + "')";
break;
case "like":
sqlwhere = " where " + column + " like '%" + txtValue + "%'";
break;
default:
sqlwhere = " where " + column + condition + " '" + txtValue + "'";
break;
}
string Sql;
string sqlquery = "select * from BorrowApplicationInfo ";
if (sqlwhere.ToString().Trim().Length > 0)
{
Sql = sqlquery + sqlwhere;
}
else
{
Sql = sqlquery;
}
this.GridView1.DataSource = PropertyBLL.GetPropertyBySql(Sql);
this.GridView1.DataBind();
this.HiddenField1.Value = Sql;
}
protected void bt_export_Click(object sender, EventArgs e)
{
CreateExcelFile();
}
public void CreateExcelFile()
{ //在服务器生成EXCEL文件
//ls_search_sql = Request.
string ls_search_sql;
ls_search_sql = Request.Form["HiddenField1"].ToString().Trim();
if (ls_search_sql.Length > 0)
{
this.GridView1.DataSource = PropertyBLL.GetPropertyBySql(ls_search_sql);
this.GridView1.DataBind();
}
else
{
this.GridView1.DataSource = PropertyBLL.GetPropertyInfo();
this.GridView1.DataBind();
}
string ls_filename = "AssetInfo";
string ls_filepath = "";
//创建一个表,并从数据窗口中转成DataTable;
DataTable dt = new DataTable();
dt = GridView2DataTable(this.GridView1);
ls_filepath = ImportExportExcel.DatatableToExcel(dt, "设备信息", "Sheet1", ls_filename);
//从服务器导出EXCEL文件,相当于在客户机打开另存窗口;
SaveFile(ls_filename+".xls", ls_filepath);
}
public void SaveFile(string ls_filename, string ls_filepathe)
{ //导出服务器的指定文件;
if (!File.Exists(ls_filepathe))
{ //文件不存在则直接退出不进行导出
Response.Write("<script>alert('文件不存在,无法下载!')</script>");
return;
}
System.IO.FileInfo fileInfo = new System.IO.FileInfo(ls_filepathe);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + ls_filename);
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/ms-excel";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile(fileInfo.FullName);
Response.Flush();
Response.End();
}
public DataTable GridView2DataTable( GridView gv)
{
DataSet ds = new DataSet();
DataTable examtable = new DataTable();
long ll_count = 0;
string ls_column = "";
ll_count = gv.Columns.Count;
for (int i = 0; i < ll_count; i++)
{
ls_column = gv.Columns[i].HeaderText;
examtable.Columns.Add(ls_column, typeof(string));
}
for (int i = 0; i < gv.Rows.Count; i++)
{
DataRow dr = examtable.NewRow();
for (int j = 0; j < ll_count; j++)
{
dr[j] = gv.Rows[i].Cells[j].Text.Trim().ToString();
}
examtable.Rows.Add(dr);
}
return examtable;
}
}
发表评论
-
改变gridview选中行的背景色
2011-05-05 16:16 3133protected void gridView_OnR ... -
列隐藏或显示
2011-05-05 16:13 1177public string ls_listcolumn = & ... -
GridView通过列名取索引
2011-05-05 11:26 1669代码 public int GetColumnIndex( ... -
gridview指定列取值并修改指定列的值
2011-05-05 10:14 4104http://shanyou.cnblogs.com/arch ... -
转]asp.net 母版页使用详解
2011-05-01 09:17 1263http://jcobra.blog.163.com/bl ... -
C# .net 获取日期
2011-04-21 20:43 976DateTime.Now; 获取日期加时间 格式:2007- ... -
给下打列表框增加数据
2011-04-21 20:40 806//先定义来源 Maticsoft.BLL.ud_pub_w ... -
C#常用正则表达试
2011-04-21 18:05 1334整数或者小数:^[0-9]+\.{0,1}[0-9]{0,2} ... -
水晶报表读取Web.config 登陆设置
2011-04-14 21:54 2734大家在基于webform中使 ... -
水晶报表(参数)
2011-04-13 17:31 845using CrystalDecisions.Cryst ... -
Excel 数据导入导出
2011-04-12 21:49 1391//导出控件Aspose.Cells 必须引用该控件 usi ... -
修改列名
2011-04-12 16:14 899GridView1.DataSource = dt; Gri ... -
加DataWindow .Net控件到Microsoft Visual Studio
2011-04-12 00:03 1118加DataWindow .Net控件到Microsoft Vi ... -
PB webserver 开发示例
2010-07-21 20:55 2826powerbuilder开发平台一直在发展,至pb9开始便已经 ... -
XP默认登录
2010-05-28 08:20 715第一种是修改注册表 这种方法比较麻烦,而且要求对注册 ... -
datawindow.net 数据库连接方
2010-04-27 09:29 1717datawindow.net 在VS2008连接 ... -
在Windows平台使用Apache2.2和Mongrel运行Ruby on Rails
2009-01-13 14:36 897在Windows平台使用Apache2.2和Mongrel运行 ... -
Eclipse下的rails开发环境建立(修正)
2009-01-13 11:55 28191.解压eclipse-platform-3.2.2-win ... -
Ruby on Rails 安装札记
2009-01-09 14:28 2077第一,安装ruby,首先从 http://www.ruby-l ... -
学习ruby on rails的视频教程和电子书下载
2009-01-08 14:36 430525个了,都不大,下载速度很快! http://www.ra ...
相关推荐
用C#语言从服务器下载文件。 用C#语言从服务器下载文件。
c#从ftp服务器上下载文件 丢给浏览器响应
C#下载IIS上flash,并保存到相应的路径。在网上找个一个例子,学习一下。也给需要这方面资料的人。共享一下。
C#FTP操作:上传、下载、在服务器上创建文件夹、删除服务器上的文件
关于C#编写的服务器端接收文件的一些问题
主要为大家详细介绍了C#如何连接服务器共享文件夹,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
C#多服务器多文件上传实例,并发,集群对考虑在内
C# 对移动云服务器文件进行下载或上传实例操作源代码
C# WebSocketServer服务器源代码.zip
从指定服务器上利用多线程下载网上的文件到本地指定的文件夹下.
C# 实现对Ftp服务器文件各种操作 文件上传下载 文件目录 创建删除
c#实现FTP服务器, 功能 ①、按标准FTP协议登录FTP服务器,进行身份验证; ②、显示远程目录、文件列表,进行目录切换; ③、目录、文件列表的排序显示(文件名、时间、类型); ④、能上传文件、下载、删除文件...
C# ftp连接到服务器,可从服务器上下载或上传文件!亲测可用!
c#传递url下载文件 下载远程服务器的文件
采用winform开发的下载文件的功能,使用WebClient中的DownloadFile方法
C# winfrom中webservice接口连接服务器上传图片和下载图片。 上传图片和下载图片,使用的时候先要在你要上传的服务端用IIS发布webservice接口 传输图片
采用C#语言,实现通过FTP协议获取服务器的文件列表和下载文件-Using C# language, to achieve access to the server via FTP protocol file list and download files
C#模拟上传下载文件服务器的一个程序,免费资源。希望大家喜欢、
2、实现功能为:A服务器上某个文件被创建/修改后,该文件要同步到B、C、D上 3、在B、C、D上建立FTP服务器 4、在程序中设置各FPT路径及登录口令 5、在程序中设置监测A的文件类型 6、Bin中安装bat进行 系统服务 安装,...