随笔分类 -  代码

代码片段
摘要:publicboolIsConnected(){SqlConnectionconnection=newSqlConnection(connectionString);//connectionString数据库连接字符串try{if(connection.State!=ConnectionState.Open){connection.Open();}returntrue;}catch{returnfalse;}} 阅读全文
posted @ 2012-07-04 23:37 盈不足 阅读(178) 评论(0) 推荐(0)
摘要://在Form1窗体中,按钮事件中,Form2form=newForm2();form.FormBorderStyle=FormBorderStyle.None;form.TopLevel=false;//指示子窗体非顶级窗体this.panel1.Controls.Add(form);//将子窗体载入form.Show(); 阅读全文
posted @ 2012-07-04 21:16 盈不足 阅读(150) 评论(0) 推荐(0)
摘要:1)弹出新窗体,设置大小 必须用Javascript程序解决,程序片段如下Window.open("abc.aspx","new","height=430,width=550");window.open('send.aspx','newwindow','height=430px,width=550px,top=50,left=30,toolbar=no,menubar=no,scrollbars=no,visizable=no,location=no,status=no');2)Grid 阅读全文
posted @ 2012-03-17 10:56 盈不足 阅读(174) 评论(0) 推荐(0)
摘要:1)获取数据表,第五行,第三列。myDataTable.Rows[4][2];2)获取第一行DataRowmyDataRow=myDataTabe.Row[0];myDataRow[4].ToString();//第一行第五个元素(第五列)myDataRow["属性值"]; 阅读全文
posted @ 2012-03-17 01:11 盈不足 阅读(157) 评论(0) 推荐(0)
摘要:第一:用一个单个字符分割stringstr="aaa,bbb,ccc";string[]strArr=str.Split(',');第二:用多个单个字符分割stringstr="aajbbkccjddkee";char[]charArr=newchar[]{'j','k'};stringStrArray=str.Split(charArr);第三:用字符串分割stringstr="aajkbbjkccjkddjkee";stringsArr=newstring[]{"js&qu 阅读全文
posted @ 2012-02-13 23:41 盈不足 阅读(492) 评论(0) 推荐(0)
摘要:1,获取内容,用Label控件 在text中的绑定表达式:Eval("contect")2,跳转URL,用HyperLink控件 在NavigateUrl中的绑定表达:Eval("url")其中,url为http://www.cnblogs.com/3,打开新连接并传值,用HyperLink控件在NavigateUrl中的绑定表达:"ShowWebFolder/ShowWebForm3.aspx?id="+DataBinder.Eval(Container.DataItem,"id") 4,调用后台方法:后台c#代 阅读全文
posted @ 2009-12-21 10:48 盈不足 阅读(181) 评论(0) 推荐(0)
摘要:一,判断某个字符中是否含有特定字符:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->publicvoidFindStringchar(stringA,stringB){if(A.IndexOf(B)>-1){Console.WriteLine("存在!");}else{Console.WriteLine("不存在!");}}例如:string A="abceFC(a";stri 阅读全文
posted @ 2009-10-20 12:06 盈不足 阅读(324) 评论(0) 推荐(0)
摘要:1)输入:0243333555 输出:024-3333555 string number="0243333555"; number=number.Insert(3,"-"); 用这种方法,可以随便改变字符串的形状, 例如变成:024-3333-555 只须:number.Insert(7,"-").Insert(3,"-"); 阅读全文
posted @ 2009-08-02 13:40 盈不足 阅读(219) 评论(1) 推荐(0)