DataGrid2
1、DataGrid的button属性设置
CommandName="ToEdit":
对其中的button按钮进行选择:
CommandArgument='<%#Eval("ID") %>':
可以在后台的DataGrid1_ItemCommand1中获取当前按下的button按钮所在行的ID:
string keyId = e.CommandArgument.ToString();
也可以直接在DataGrid属性里配置ID:
DataKeyField="ID":
string keyId = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
2、DataGrid中的button,实现导出word文档
如:
if (e.CommandName.ToLower() == "toword") //导出word
{
//导出word
string ID = e.CommandArgument.ToString();
object missing = System.Reflection.Missing.Value;
string FileName = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath);
//string aa = ;
string TemplateFile = FileName + @"Template\文件名字.doc";//带有格式的空的“文件名字.doc”文档
FileName += @"FckUploadfile\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc";
File.Copy(TemplateFile, FileName);
FileInfo fi = new FileInfo(FileName);
//判断文件属性是否只读?是则修改为一般属性再保存
if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
{
fi.Attributes = FileAttributes.Normal;
}
Microsoft.Office.Interop.Word.Application App = new Microsoft.Office.Interop.Word.Application();
try
{
object Obj_FileName = FileName;
object Visible = false;
object ReadOnly = false;
Microsoft.Office.Interop.Word.Document Doc = App.Documents.Open(ref Obj_FileName, ref missing, ref ReadOnly, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref Visible,
ref missing, ref missing, ref missing,
ref missing);
Doc.Activate();
// Get the data and fill the data( PersonName ,PersonResume) to the appoint BookMark
DataRow row = AccountRule.导出试用期考核表信息获取(ID).Rows[0];
object BookMarkName = "姓名";
object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark;
Doc.ActiveWindow.Selection.GoTo(ref what, ref missing, ref missing, ref BookMarkName);
Doc.ActiveWindow.Selection.TypeText(row["姓名"].ToString());
BookMarkName = "性别";
Doc.ActiveWindow.Selection.GoTo(ref what, ref missing, ref missing, ref BookMarkName);
Doc.ActiveWindow.Selection.TypeText(row["姓名"].ToString());
BookMarkName = "出生年月";
Doc.ActiveWindow.Selection.GoTo(ref what, ref missing, ref missing, ref BookMarkName);
Doc.ActiveWindow.Selection.TypeText(row["出生年月"].ToString());
BookMarkName = "政治面貌";
Doc.ActiveWindow.Selection.GoTo(ref what, ref missing, ref missing, ref BookMarkName);
Doc.ActiveWindow.Selection.TypeText(row["政治面貌"].ToString());
BookMarkName = "单位";
Doc.ActiveWindow.Selection.GoTo(ref what, ref missing, ref missing, ref BookMarkName);
Doc.ActiveWindow.Selection.TypeText(row["单位"].ToString());
BookMarkName = "从事工作";
Doc.ActiveWindow.Selection.GoTo(ref what, ref missing, ref missing, ref BookMarkName);
Doc.ActiveWindow.Selection.TypeText(row["从事工作"].ToString());
BookMarkName = "学历学位";
Doc.ActiveWindow.Selection.GoTo(ref what, ref missing, ref missing, ref BookMarkName);
Doc.ActiveWindow.Selection.TypeText(row["学历"].ToString() + "\r\n" + row["学位"].ToString());
Doc.ActiveWindow.Selection.MoveDown(Microsoft.Office.Interop.Word.WdUnits.wdLine, 6);
BookMarkName = "试用期起止时间";
Doc.ActiveWindow.Selection.GoTo(ref what, ref missing, ref missing, ref BookMarkName);
Doc.ActiveWindow.Selection.TypeText(row["试用期起止时间"].ToString());
BookMarkName = "个人总结";
Doc.ActiveWindow.Selection.GoTo(ref what, ref missing, ref missing, ref BookMarkName);
Doc.ActiveWindow.Selection.TypeText(Convert.IsDBNull(row["个人总结"]) ? string.Empty : row["个人总结"].ToString());
File.SetAttributes(FileName, FileAttributes.Normal);
Doc.Save();
// Save the File and change the File as stream
object IsSave = true;
Doc.Close(ref IsSave, ref missing, ref missing);
Get(FileName);
}
finally
{
App.Quit(ref missing, ref missing, ref missing);
}
//string url = Request.ApplicationPath + @"/qgy/dybg_File.aspx?KeyId=" + keyId;
//Response.Write("<script>window.open('" + url + "','','target=_blank,scrollbars=yes,top=100,left=200,width=600,height=300,scrolling=1');</script>");
}
}
public void Get(string fileName)
{
string paths = Request.MapPath("../FckUploadfile");
string file = Path.Combine(paths, fileName);
FileInfo fi = new FileInfo(file);
if (fi.Exists == true)
{
// const long ChunkSize = 1024;
// byte[] buffer = new byte[ChunkSize];
//Response.Clear();
FileStream istream = File.OpenRead(file);
try
{
byte[] buffer = new byte[istream.Length];
istream.Read(buffer, 0, buffer.Length);
istream.Seek(0, SeekOrigin.Begin);
Response.BinaryWrite(buffer);
//long Data = istream.Length;
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(file.Substring(file.LastIndexOf("\\") + 1)));
}
finally
{
}
}
}
DataGrid2的更多相关文章
- Struts2 easy UI插件
一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...
- Easy UI常用插件使用
一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tree([settings]); 常 ...
- Struts2中的EasyUI
Struts2中的EasyUI 一.easy UI是类似于jQuery UI的插件库,它提供了丰富的各种常用插件:tree.datagrid... tree插件: 语法:$(selector).tre ...
- miniui中常用的状态显示方式
1.查询sys_code表得到对应的状态 考生状态:<input class="mini-combobox" style="" textField=&qu ...
- java_easyui体系之DataGrid(4)[转]
一:简介 在前面DataGrid(3)的基础上添加后台的实现.本来是想只搭建前台页面的.后台不写.现在觉得还是都实现好点.从真实情况出发.后台用的ssh. 1. 新增冻结列功能. 2. 实现界面的添加 ...
- java_easyui体系之DataGrid(3)[转]
一:简介 在2的基础上实现增删改.增.改都是通过行编辑来实现的.具体业务逻辑: 1. 增加一条记录的时候: a) 在datagrid表格最前端增加一行(当然也可在指定位置增加.)增加的行的字段必须与要 ...
- java_easyui体系之DataGrid(2)[转]
一:简介 在1的基础上添加layout组件.实现通过条件动态的从后台查询数据到前台展示.使用的方式是将查询单独作为一个layout中的一个面板. 二:关键之处 1.效果图: 2.左侧的折叠组件: 折叠 ...
- csharp: Data binding in WPF DataGrid control
<Window x:Class="WpfProjectDemo.MainWindow" xmlns="http://schemas.microsoft.com/wi ...
- JQuery EasyUI之DataGrid列名和数据列分别设置不同对齐方式(转)
需求如下 现有数据列三列 Name,Age,CreateDate 数据 张三,18,2000-12-09 :12:34:56 李四,28,2000-12-09 :12:34:56 王麻子,38,200 ...
随机推荐
- 剑指 offer set 1 二维数组中查找
总结 1. 二维数组搜索题遇到两个了, 一个是 Leetcode 上 search in 2D matrix. 那道题比较简单, 因为下一行的所有元素大于上一行的. 这道题对二维矩阵的要求比较松, 起 ...
- javascript 变量解析
1.JavaScript中,你可以在函数的任何位置声明多个var语句,并且它们就好像是在函数顶部声明一样发挥作用,这种行为称为 hoisting(悬置/置顶解析/预解析).当你使用了一个变量,然后不久 ...
- iOS iphone5屏幕适配 autosizing
转自:http://blog.sina.com.cn/s/blog_a843a8850101jxhh.html iphone5出来了,从不用适配的我们也要像android一样适配不同分辨率的屏幕了. ...
- j疑难杂症:java.lang.VerifyError: class org.hibernate.type.WrappedMaterializedBlobType overrides final method getReturnedClass.()Ljava/lang/Class;
问题: java.lang.VerifyError: class org.hibernate.type.WrappedMaterializedBlobType overrides final meth ...
- 实例源码--IOS高仿微信打飞机游戏(完整功能)
下载源码 技术要点: 1. IOS游戏开发基础框架 2. 高仿打飞机游戏 3. 游戏背景音频技术 4.源码详细的中文注释 ……. 详细介绍: 1. IOS游戏开发基础框架 此套源码为涉及IOS游戏开发 ...
- oracle中to_date() 与 to_char() 日期和字符串转换
to_date("要转换的字符串","转换的格式") 两个参数的格式必须匹配,否则会报错. 即按照第二个参数的格式解释第一个参数. to_char(日期,& ...
- redis实现与分析
http://www.kuqin.com/shuoit/20141019/342739.html
- C中存储类、链接和内存管理
在C语言中,有5种不同的存储类型,即存储类.在介绍存储类之前,需要首先简单介绍几个术语.如下: 作用域:描述程序中可以访问一个标识符的一个或多个区域.一个C变量的作用域可以是代码块作用域.函数原型作用 ...
- Windows OpenVPN Client and tls-auth
The official Windows OpenVPN client does not seem to work properly with the tls-auth option if a key ...
- PHP常用文件函数和目录函数整理
一.常用文件函数库 1.basename(); -- 返回路径中的文件名部分. string basename ( string $path [, string $suffix ] ) //给出一个包 ...