說明:在Excel中建立下拉式選單供user選取,該怎麼做?
作法:
1. 需先開啟「開發人員」模式:
Excel 2010&2013:檔案->選項->自訂功能區->右側有「開發人員」打勾->確定
Excel 2007:Office按鈕->Excel選項->常用->勾選「在功能區顯示[開發人員]索引標籤」->確定
2. 在分頁上輸入下拉式選單要顯示的值->點選Tab上新增的開發人員->插入->點選下拉式選單圖示
3. 在分頁上點擊左鍵拉入下拉式選單->右鍵出現控制項格式->選擇控制->設定輸入範圍(圈選要顯示的值)->確定
參考資料:
http://blog.bestdaylong.com/2012/10/excel-2010.html
http://hy-chou.blogspot.tw/2013/01/excel.html
2013年12月17日 星期二
[Crystal Report] 參數欄位設定
說明:有時需取得Client端的變數值,該怎麼把值塞到報表上?
作法:
1. 在test.rpt檔上欄位總管->參數欄位->右鍵新增->輸入名稱與選取數值類型->拉到報表上
2. 在test.aspx.cs
//建構一ReportDocument object
private ReportDocument rdTest = new ReportDocument();
string strRptName = Page.MapPath("test.rpt");
//Load
rdTest.Load(strRptName);
//設定參數欄位的現值
rdTest.SetParameterValue(string name, object val);
//Bind
CrystalReportViewer1.ReportSource = rdTest;
CrystalReportViewer1.DataBind();
參考資料:
http://www.wretch.cc/blog/JohnDX/14586953
作法:
1. 在test.rpt檔上欄位總管->參數欄位->右鍵新增->輸入名稱與選取數值類型->拉到報表上
2. 在test.aspx.cs
//建構一ReportDocument object
private ReportDocument rdTest = new ReportDocument();
string strRptName = Page.MapPath("test.rpt");
//Load
rdTest.Load(strRptName);
//設定參數欄位的現值
rdTest.SetParameterValue(string name, object val);
//Bind
CrystalReportViewer1.ReportSource = rdTest;
CrystalReportViewer1.DataBind();
參考資料:
http://www.wretch.cc/blog/JohnDX/14586953
[.NET] .NET Reflector
說明:可用來反組譯.NET平台的dll或exe,目前最新版本為Reflector 8。
官網:http://www.red-gate.com/products/dotnet-development/reflector/
參考資料:
http://mitblog.pixnet.net/blog/post/34558377-.net-reflector-7
官網:http://www.red-gate.com/products/dotnet-development/reflector/
參考資料:
http://mitblog.pixnet.net/blog/post/34558377-.net-reflector-7
2013年12月4日 星期三
[C#] DateTime轉字串需顯示毫秒
說明:
使用DateTime.ToString("時間格式"),顯示到毫秒該怎麼做?
作法:
DateTime.ToString("yyyyMMddhhmmssfff"),fff 格式包含毫秒值中任何結尾的零。
參考資料:
http://msdn.microsoft.com/zh-tw/library/bb882581(v=vs.110).aspx
使用DateTime.ToString("時間格式"),顯示到毫秒該怎麼做?
作法:
DateTime.ToString("yyyyMMddhhmmssfff"),fff 格式包含毫秒值中任何結尾的零。
參考資料:
http://msdn.microsoft.com/zh-tw/library/bb882581(v=vs.110).aspx
2013年12月3日 星期二
[C#] 透過SqlConnectionStringBuilder設定連線字串
說明:一般連線字串大多透過ConfigurationManager class
來讀取寫在web.config的連線字串,若沒web.config或想修改連線字串時,該如何做?
(ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;)
作法:
使用SqlConnectionStringBuilder class:
public static SqlConnectionStringBuilder connStr;
public DataAccess()
{
connStr = new SqlConnectionStringBuilder();
connStr.DataSource = "IP";
connStr.InitialCatalog = "DB name";
connStr.UserID = "UserID";
connStr.Password = "Password";
}
參考資料:
http://stackoverflow.com/questions/16511244/how-to-create-connection-string-dynamically-in-c-sharp
來讀取寫在web.config的連線字串,若沒web.config或想修改連線字串時,該如何做?
(ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;)
作法:
使用SqlConnectionStringBuilder class:
public static SqlConnectionStringBuilder connStr;
public DataAccess()
{
connStr = new SqlConnectionStringBuilder();
connStr.DataSource = "IP";
connStr.InitialCatalog = "DB name";
connStr.UserID = "UserID";
connStr.Password = "Password";
}
參考資料:
http://stackoverflow.com/questions/16511244/how-to-create-connection-string-dynamically-in-c-sharp
[C#] StringBuilder語法紀錄
使用時機:
大量字串串接時,如迴圈中組字串。
1.建立StringBuilder object
StringBuilder sb = new StringBuilder();
2. append字串
sb.Append("test");
3. 移除字串
sb.Remove(int startIndex, int Length);
sb.Remove(sb.Length-1, 1);
4. 轉為string type
sb.ToString();
參考資料:
http://msdn.microsoft.com/zh-tw/library/2839d5h5(v=vs.110).aspx
http://msdn.microsoft.com/zh-tw/library/system.text.stringbuilder(v=vs.110).aspx
大量字串串接時,如迴圈中組字串。
1.建立StringBuilder object
StringBuilder sb = new StringBuilder();
2. append字串
sb.Append("test");
3. 移除字串
sb.Remove(int startIndex, int Length);
sb.Remove(sb.Length-1, 1);
4. 轉為string type
sb.ToString();
參考資料:
http://msdn.microsoft.com/zh-tw/library/2839d5h5(v=vs.110).aspx
http://msdn.microsoft.com/zh-tw/library/system.text.stringbuilder(v=vs.110).aspx
[ASP.NET] Enable/Disable GridView裡的LinkButton
說明:在GridView的樣板裡放了LinkButton,並想根據點選LinkButton後紀錄的Status來繫結LinkButton最新的狀態(Enable/Disable)。
例:
Process_No Process_Name Check-in Check-out
1 test LinkButton1 LinkButton2
若Process Check-in後,則LinkButton1 Disable LinkButton2 Enable
作法:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button btnCheckIn = (Button)e.Row.FindControl("btnCheckIn");
Button btnCheckOut = (Button)e.Row.FindControl("btnCheckOut");
btnCheckIn.Enabled = false;
btnCheckOut.Enabled = false;
//取得繫結於GridView中各row的Check_Status值
string strCheckStatus = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Check_Status"));
//Initial
if (strCheckStatus == "0")
{
btnCheckIn.Enabled = true;
}
//Check in
else if (strCheckStatus == "1")
{
btnCheckOut.Enabled = true;
}
}
}
參考來源:
http://stackoverflow.com/questions/17207271/enable-and-disable-link-button-on-gridview
例:
Process_No Process_Name Check-in Check-out
1 test LinkButton1 LinkButton2
若Process Check-in後,則LinkButton1 Disable LinkButton2 Enable
作法:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button btnCheckIn = (Button)e.Row.FindControl("btnCheckIn");
Button btnCheckOut = (Button)e.Row.FindControl("btnCheckOut");
btnCheckIn.Enabled = false;
btnCheckOut.Enabled = false;
//取得繫結於GridView中各row的Check_Status值
string strCheckStatus = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Check_Status"));
//Initial
if (strCheckStatus == "0")
{
btnCheckIn.Enabled = true;
}
//Check in
else if (strCheckStatus == "1")
{
btnCheckOut.Enabled = true;
}
}
}
參考來源:
http://stackoverflow.com/questions/17207271/enable-and-disable-link-button-on-gridview
訂閱:
文章 (Atom)