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 ...
随机推荐
- IOS实用功能之截图(来自相册和拍照)
// // ViewController.m // MyImagePicker1.0 // // Created by Mac on 14-7-14. // Copyright (c) 201 ...
- WCF关于VS2010的配置
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE 下的 devenv.exe.config 在 <configura ...
- Android root 原理
Android root 原理 0x00 关于root linux和类Unix系统的最初设计都是针对多用户的操作系统,对于用户权限的管理很非常严格的,而root用户(超级用户)就是整个系统的唯一管理员 ...
- 在加载模块时出现cannot insert '*.ko': Device or resource busy错误
制作了一个模块,在加载是出现了cannot insert '*.ko': Device or resource busy错误. 原因: 是由于模块使用的是静态分配设备号,而这个设备号已经被系统中的其他 ...
- webrtc学习(二): audio_device之opensles
audio_device是webrtc的音频设备模块. 封装了各个平台的音频设备相关的代码 audio device 在android下封装了两套音频代码. 1. 通过jni调用java的media ...
- seleniu IDE 点点滴滴
在使用selenium webdriver +python 的过程中遇见了许多的问题,这些问题在网上都没有找到很好的答案,后来在看selenium IDE的时候发现这里面有很好的解决方法,写写.记记. ...
- iOS7开发中的新特性
iOS7到现在已经发布了有一段时间了.相信你现在已经了解了它那些开创性的视觉设计,已经了解了它的新的API,比如说SpirteKit,UIKit Dynamics以及TextKit,作为开发者 ...
- 剑指Offer01 杨氏数组寻值
/************************************************************************* > File Name: 001.c > ...
- 剑指Offer06 旋转数组的最小值
/************************************************************************* > File Name: 06_MinNum ...
- could not read data from '/Users/xxxx/myapp-Info.plist'
xcode编译报错如下: could not read data from '/Users/iamme/Documents/XCode/myapp/myapp/myapp-Info.plist': T ...