随笔分类 -  C#

C# 资料大全
摘要:http://club.topsage.com/thread-371991-1-1.html 阅读全文

posted @ 2012-03-28 14:50 AndyCai 阅读(255) 评论(0) 推荐(0)

用流打开open office ods 文件
摘要:string template = "Template.ods";string path = Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings["TemplateSavePath"].ToString().Trim()+template);Response.Clear();Response.AppendHea... 阅读全文

posted @ 2010-07-09 14:29 AndyCai 阅读(1658) 评论(0) 推荐(0)

通过流打开一个Excel文件
摘要:string templateExcel = "xxx.xls"; string path = Server.MapPath(@"Template\") + templateExcel; //路径 System.IO.FileInfo file = new System.IO.FileInfo(path); Response.AddHeader("Content-Disposition", "at... 阅读全文

posted @ 2010-06-03 13:43 AndyCai 阅读(229) 评论(0) 推荐(0)

常用的C#正则表达式!
摘要:来自网络:"^\d+$" //非负整数(正整数 + 0) "^[0-9]*[1-9][0-9]*$" //正整数 "^((-\d+)|(0+))$" //非正整数(负整数 + 0) "^-[0-9]*[1-9][0-9]*$" //负整数 "^-?\d+$" //整数 "^\d+(\.\d+)?$" //非负浮点数(正浮点数 + 0) "^(([0-9]+\.[0-9]*[1-9][0-9]*)|... 阅读全文

posted @ 2010-05-31 14:33 AndyCai 阅读(174) 评论(0) 推荐(0)

Excel 读出列中的数值 为空.
摘要:最近项目中有用到上传Excel .Excel 中列比较多,列中的数据有些为空,有些是有值的.在测试的过程中发现有时能读到列中的值,有时为空.有个和Excel 格式设置有关.如果这个列的前8行数据为空,又没有设置过格式,这时驱动就默认为文本,下面的行如果这个列有数值,就会读出为空.需要把所有要填写数值的格子设置为数值类型,Excel 才能正常读取.参考:http://msdn2.microsoft.... 阅读全文

posted @ 2010-04-27 09:32 AndyCai 阅读(548) 评论(0) 推荐(0)

两结构相同DataTable 合并
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--publicDataTableMergeTable(DataTableorgDt,DataTablenewDt){object[]obj=newobject[newDt.Columns.Count];... 阅读全文

posted @ 2010-03-26 13:33 AndyCai 阅读(198) 评论(0) 推荐(0)

DataView 转成DataTable
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--publicDataTableCreateTable(DataViewobDataView){if(null==obDataView){thrownewArgumentNullException("D... 阅读全文

posted @ 2010-03-26 13:32 AndyCai 阅读(208) 评论(0) 推荐(0)

上传文件
摘要:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--protectedvoidbtnSubmit_Click(objectsender,EventArgse){try{if(this.CheckUpload()){//文件儲存路徑stringstrDQ... 阅读全文

posted @ 2009-12-15 14:11 AndyCai 阅读(191) 评论(0) 推荐(0)

GridView 中下载文件
摘要:GridView 中每一行都有一个File Name 列,显示文件名称,点击后可下载.前台GridView :<asp:TemplateField HeaderText="File Name" SortExpression="FULLFILENAME"> <itemtemplate> <asp:LinkButton id="lbnFileName" onclick="... 阅读全文

posted @ 2009-12-15 14:04 AndyCai 阅读(717) 评论(0) 推荐(0)

asp.net panel 动态加载控件
摘要:[代码] 阅读全文

posted @ 2009-10-08 10:52 AndyCai 阅读(523) 评论(2) 推荐(0)

2位小数正则表达式
摘要:项目中有一栏位只能是0.xx 的两位小数。用正则表达式check :^0.[0-9]{2}$.因为这个栏位非必填,采用asp.net 自带的RegularExpressionValidator在前台Check.RegularExpressionValidator只在有输入的情况下才起作用。 <asp:RegularExpressionValidator ID="revTFT" runat="... 阅读全文

posted @ 2009-08-26 10:46 AndyCai 阅读(4150) 评论(0) 推荐(0)

Web Service 返回XML 转DataSet
摘要:[代码] 阅读全文

posted @ 2009-08-14 10:56 AndyCai 阅读(282) 评论(0) 推荐(0)

基本的数据库操作类
摘要:Web.Config<connectionStrings><add name="TestConn" connectionString="Data Source=Andy-NB;Initial Catalog=testDB;Persist Security Info=True;User ID=testID;Password=testPWD" providerName="System... 阅读全文

posted @ 2009-07-08 10:13 AndyCai 阅读(481) 评论(0) 推荐(0)

Data Access Application Block 利用DataSet 操作DB
摘要:这几天在做一个项目的CR.此项目利用了Data Access Application Block来进行DB操作.以下代码是对一个Table 用DB.UpdateDataSet方法来操[代码]作. 阅读全文

posted @ 2009-07-03 16:14 AndyCai 阅读(229) 评论(0) 推荐(0)

ASP.Net 动态加载控件 未能加载视图状态 的解决
摘要:项目中需要通过Panel 动态加载控件.根据下拉框选择不同类型(52,64,68)来加载一些Dropdownlist 和隐藏的textbox. 52 会多加载一个显示的Textbox.出现的问题是在不同类型间转换时,其中一种情况(64转52时)出现了未能加载视图状态的错误.跟踪后的消息是:未能加载视图状态。正在向其中加载视图状态的控件树必须与前一请求期间用于保存视图状态的控件树相匹配。例如,当以动... 阅读全文

posted @ 2009-05-19 09:34 AndyCai 阅读(1225) 评论(0) 推荐(0)

C# 调WebService 报请求因 HTTP 状态 401 失败: Unauthorized 的解决
摘要:今天在C#中要用到WebService ,报了请求因 HTTP 状态 401 失败: Unauthorized 的问题.解决如下: MakerContact.MakerContact wsMakeContact = new ModelNotice.MakerContact.MakerContact(); wsMakeContact.Url = ConfigurationManager.AppSet... 阅读全文

posted @ 2009-05-13 16:09 AndyCai 阅读(2062) 评论(0) 推荐(0)

C# 用System.Net.Mail 发mail
摘要:最近项目中有用到SMTP 发Mail ,作个记录!using System.Net.Mail;using System.Net;--------------------- MailAddress MailFrom = new MailAddress(mailFrom); --aaa@xxx.com MailAddress MailTo = new MailAddress(mailTo);---b... 阅读全文

posted @ 2009-05-13 16:07 AndyCai 阅读(301) 评论(0) 推荐(0)

合并GridView 单元格
摘要:[代码] 阅读全文

posted @ 2009-05-05 13:34 AndyCai 阅读(214) 评论(0) 推荐(0)

C# 中对一些消息处理的方法.
摘要:C# 中对一些消息处理的方法./// <summary> /// 客户端脚本:alert(Msg) I; /// </summary> /// <param name="Msg">要显示的消息</param> /// <returns>alert函数的客户端脚本</returns> public static string C... 阅读全文

posted @ 2009-05-04 09:21 AndyCai 阅读(253) 评论(0) 推荐(0)

导航