[SQL]無法為連結伺服器的 OLE DB 提供者 "SQLNCLI11" 啟動巢狀交易。因為 XACT_ABORT 選項已設定為 OFF,所以必須要有巢狀交易。
LINK SERVER 開啟分散式交易
SET XACT_ABORT ON
DELETE FROM DKF.IF.dbo.IFCOM_INVNO
WHERE INVNO = @I_CHR_INVOID
SET XACT_ABORT OFF
[C# .Net]控制項擁有的 SelectedValue 無效,因為它不在項目清單中
控制項擁有的 SelectedValue 無效,因為它不在項目清單中
1. 當來源為DB datasource為SQL產出
請注意,"ABC" 不等於 "ABC " => 因後方空白不被承認
檢查SQL語法是否有做處理
2. 來源為定值或輸入,使用DEbug mode 檢查items中是否沒有SelectedValue
範例加入預設項目的寫法
從DB抓來的資料後,直接加入data row 再bind
DataTable dtOftenACC = db.GetOftenACC(txtIFFIA20F040.Text, ddlIFFIA20FD1015.SelectedValue, txtIFFIA20FD1003.Text, string.Empty, string.Empty);
if (dtOftenACC.Rows.Count > 0)
{
string tmpOftenACC = "";
tmpOftenACC = fddlOftenACC.SelectedValue.ToString();
fddlOftenACC.DataValueField = "SEG";
fddlOftenACC.DataTextField = "SEGNM";
DataRow dr = dtOftenACC.NewRow();
dr["SEGNM"] = "已自行挑選科目";
dr["SEG"] = "ZZ";
DataRow dr2 = dtOftenACC.NewRow();
dr2["SEGNM"] = "請選擇";
dr2["SEG"] = "1";
dtOftenACC.Rows.InsertAt(dr, 0);
dtOftenACC.Rows.InsertAt(dr2, 0);
fddlOftenACC.DataSource = dtOftenACC;
fddlOftenACC.DataBind();
if (tmpOftenACC == "")
{
fddlOftenACC.SelectedValue = "1";
}
else
{
fddlOftenACC.SelectedValue = tmpOftenACC;
}
}
1. 當來源為DB datasource為SQL產出
請注意,"ABC" 不等於 "ABC " => 因後方空白不被承認
檢查SQL語法是否有做處理
2. 來源為定值或輸入,使用DEbug mode 檢查items中是否沒有SelectedValue
範例加入預設項目的寫法
從DB抓來的資料後,直接加入data row 再bind
DataTable dtOftenACC = db.GetOftenACC(txtIFFIA20F040.Text, ddlIFFIA20FD1015.SelectedValue, txtIFFIA20FD1003.Text, string.Empty, string.Empty);
if (dtOftenACC.Rows.Count > 0)
{
string tmpOftenACC = "";
tmpOftenACC = fddlOftenACC.SelectedValue.ToString();
fddlOftenACC.DataValueField = "SEG";
fddlOftenACC.DataTextField = "SEGNM";
DataRow dr = dtOftenACC.NewRow();
dr["SEGNM"] = "已自行挑選科目";
dr["SEG"] = "ZZ";
DataRow dr2 = dtOftenACC.NewRow();
dr2["SEGNM"] = "請選擇";
dr2["SEG"] = "1";
dtOftenACC.Rows.InsertAt(dr, 0);
dtOftenACC.Rows.InsertAt(dr2, 0);
fddlOftenACC.DataSource = dtOftenACC;
fddlOftenACC.DataBind();
if (tmpOftenACC == "")
{
fddlOftenACC.SelectedValue = "1";
}
else
{
fddlOftenACC.SelectedValue = tmpOftenACC;
}
}
[SQL]執行查詢字串連接串參數寫法參考
SET @TMP_CHR_SIGGRPSEQ = 1 --20180825 --(SELECT CONVERT(int, @TMP_DEPTLEVEL))
SELECT @sql_INSERT_INTO_SIGMGRDF = 'INSERT INTO '+ @CHR_TABLENM_SIGMGRDF + ' ' --20180825
+'(COMPID, APDEPTID, SIGGRP, SIGGRPSEQ, SIGDEPTID, SIGDEPTLEVEL, SIGDEPTMGRUID) VALUES (''' --20180825
+@TMP_COMPID+''','+''''+@TMP_APDEPTID+''','+''''+@TMP_CHR_SIGGRP+''','+''''+CONVERT(VARCHAR(2), CONVERT(INT,@TMP_CHR_SIGGRPSEQ)*5)+''','+''''+@TMP_BASEDEPTID+''','+''''+@TMP_DEPTLEVEL+''','+''''+@TMP_SIGDEPTMGRUID+''')' --20190513
EXEC (@sql_INSERT_INTO_SIGMGRDF)
SELECT @sql_INSERT_INTO_WHERE_SIGDEPTLVL = 'INSERT INTO ' + @CHR_TABLENM_SIGDEPTLVL + ' VALUES ('+@TMP_DEPTLEVEL+')'
print '[dbo].[HD_USP_INSERT_APDEPT5T_W_I01].88.sql_INSERT_INTO_WHERE_SIGDEPTLVL='+@sql_INSERT_INTO_WHERE_SIGDEPTLVL
print '[dbo].[HD_USP_INSERT_APDEPT5T_W_I01].TMP_DEPTLEVEL='+@TMP_DEPTLEVEL
-- EXEC (@sql_SELECT_SIGDEPTLVL) --20180911
SELECT @sql_SELECT_WHERE_SIGDEPTLVL = 'SELECT * FROM ' + @CHR_TABLENM_SIGDEPTLVL + ' WHERE [DEPELVLID]=' +@TMP_DEPTLEVEL --20180911
print '[dbo].[HD_USP_INSERT_APDEPT5T_W_I01].sql_SELECT_WHERE_SIGDEPTLVL'+@sql_SELECT_WHERE_SIGDEPTLVL
SELECT @sql_INSERT_INTO_SIGMGRDF = 'INSERT INTO '+ @CHR_TABLENM_SIGMGRDF + ' ' --20180825
+'(COMPID, APDEPTID, SIGGRP, SIGGRPSEQ, SIGDEPTID, SIGDEPTLEVEL, SIGDEPTMGRUID) VALUES (''' --20180825
+@TMP_COMPID+''','+''''+@TMP_APDEPTID+''','+''''+@TMP_CHR_SIGGRP+''','+''''+CONVERT(VARCHAR(2), CONVERT(INT,@TMP_CHR_SIGGRPSEQ)*5)+''','+''''+@TMP_BASEDEPTID+''','+''''+@TMP_DEPTLEVEL+''','+''''+@TMP_SIGDEPTMGRUID+''')' --20190513
EXEC (@sql_INSERT_INTO_SIGMGRDF)
SELECT @sql_INSERT_INTO_WHERE_SIGDEPTLVL = 'INSERT INTO ' + @CHR_TABLENM_SIGDEPTLVL + ' VALUES ('+@TMP_DEPTLEVEL+')'
print '[dbo].[HD_USP_INSERT_APDEPT5T_W_I01].88.sql_INSERT_INTO_WHERE_SIGDEPTLVL='+@sql_INSERT_INTO_WHERE_SIGDEPTLVL
print '[dbo].[HD_USP_INSERT_APDEPT5T_W_I01].TMP_DEPTLEVEL='+@TMP_DEPTLEVEL
-- EXEC (@sql_SELECT_SIGDEPTLVL) --20180911
SELECT @sql_SELECT_WHERE_SIGDEPTLVL = 'SELECT * FROM ' + @CHR_TABLENM_SIGDEPTLVL + ' WHERE [DEPELVLID]=' +@TMP_DEPTLEVEL --20180911
print '[dbo].[HD_USP_INSERT_APDEPT5T_W_I01].sql_SELECT_WHERE_SIGDEPTLVL'+@sql_SELECT_WHERE_SIGDEPTLVL
[JavaScript]將日期格式化傳給 .NET 控制項和時間的加減
//取得現在時間 var dt = new Date();
//日期格式化傳給textbox
//此字串可直接傳給SQL存檔為datetime document.getElementById("ctl00_ContentPlaceHolder1_ftbCRTDT_D3").value = dt.format("yyyy-MM-dd HH:mm:ss").toString();
var dt = new Date();
year = dt.getFullYear();
month = dt.getMonth();
day = dt.getDate();
if(fgvD3.rows[i2].cells[3].children[0].value == '教育訓練') {
fgvD3.rows[i2].cells[6].getElementsByTagName("input")[0].value = new Date(this.year + 2, this.month, this.day).format("yyyyMMdd").toString();
}
if (fgvD3.rows[i2].cells[3].children[0].value == 'show room展示') {
fgvD3.rows[i2].cells[6].getElementsByTagName("input")[0].value = new Date(this.year + 2, this.month, this.day).format("yyyyMMdd").toString();
}
if (fgvD3.rows[i2].cells[3].children[0].value == '測試用') {
fgvD3.rows[i2].cells[6].getElementsByTagName("input")[0].value = new Date(this.year + 1, this.month, this.day).format("yyyyMMdd").toString();
}
if (fgvD3.rows[i2].cells[3].children[0].value == '其他') {
fgvD3.rows[i2].cells[6].getElementsByTagName("input")[0].value = new Date(this.year , this.month+3, this.day).format("yyyyMMdd").toString();
}
[SQL]PIVOT使用,將公司階層轉向給 report 頁尾使用+UNPIVOT
select 'SIGSEQ',[050],[100],[110],[120],[130],[140],[150],[160],[170],[180],[190],[200] from
(
SELECT
A.FLOWDPTY003
--,A.FLOWDPTY007
--,B.JOBTITLEID
,C.JOBTITLENM
FROM [dbo].[FLOWDPTY] AS A
left join [IFLOW2].[dbo].[VW_HPMUSER] AS B ON A.FLOWDPTY007 = B.USERID AND A.FLOWDPTY008 = B.COMPID
left join [IFLOW2].[dbo].[VW_HPMJOBTITLE] AS C ON B.JOBTITLEID = C.JOBTITLEID AND B.COMPID =C.COMPID
where A.FLOWDPTY001='IFFIB05F'
AND A.FLOWDPTY002 = @I_CHR_SHEETNO
AND A.FLOWDPTY003 BETWEEN '050' AND '200'
) as t
PIVOT(
Max(JOBTITLENM)
for [FLOWDPTY003] in ([050],[100],[110],[120],[130],[140],[150],[160],[170],[180],[190],[200])
) as p;
轉向後
原始
(
SELECT
A.FLOWDPTY003
--,A.FLOWDPTY007
--,B.JOBTITLEID
,C.JOBTITLENM
FROM [dbo].[FLOWDPTY] AS A
left join [IFLOW2].[dbo].[VW_HPMUSER] AS B ON A.FLOWDPTY007 = B.USERID AND A.FLOWDPTY008 = B.COMPID
left join [IFLOW2].[dbo].[VW_HPMJOBTITLE] AS C ON B.JOBTITLEID = C.JOBTITLEID AND B.COMPID =C.COMPID
where A.FLOWDPTY001='IFFIB05F'
AND A.FLOWDPTY002 = @I_CHR_SHEETNO
AND A.FLOWDPTY003 BETWEEN '050' AND '200'
) as t
PIVOT(
Max(JOBTITLENM)
for [FLOWDPTY003] in ([050],[100],[110],[120],[130],[140],[150],[160],[170],[180],[190],[200])
) as p;
轉向後
原始
UNPIVOT
SELECT * FROM (
SELECT
A.CCID
,'工作檔' AS VISION
,@SQL_COMPID AS COMPID
,A.DATAYEAR
,A.SEG1
,A.SEG2
,C.SEG2NM
,A.SEG3
,C.SEG3NM
,A.SEG4
,C.SEG4NM AS SEG4NM
,A.SEG5
,C.SEG5NM AS SEG5NM
,A.SEG6
,C.SEG6NM AS SEG6NM
, A.AMT_M1
, A.AMT_M2
, A.AMT_M3
, A.AMT_M4
, A.AMT_M5
, A.AMT_M6
, A.AMT_M7
, A.AMT_M8
, A.AMT_M9
, A.AMT_M10
, A.AMT_M11
, A.AMT_M12
FROM dbo.BJMF AS A
LEFT JOIN dbo.V_ALLACCID_FROM_GL AS C ON A.CCID = C.CCID
WHERE
A.DATAYEAR = @I_CHR_DATAYEAR
AND A.YEARTYPE = @I_CHR_YEARTYPE
and A.SEG1 = @SQL_COMPID
and A.SEG2 = CASE WHEN @I_CHR_SEG2 <> '' THEN @I_CHR_SEG2 ELSE A.SEG2 END
and A.SEG3 = CASE WHEN @I_CHR_SEG3 <> '' THEN @I_CHR_SEG3 ELSE A.SEG3 END
and A.SEG4 = CASE WHEN @I_CHR_SEG4 <> '' THEN @I_CHR_SEG4 ELSE A.SEG4 END
and A.SEG5 = CASE WHEN @I_CHR_SEG5 <> '' THEN @I_CHR_SEG5 ELSE A.SEG5 END
and A.SEG6 = CASE WHEN @I_CHR_SEG6 <> '' THEN @I_CHR_SEG6 ELSE A.SEG6 END
) AS P
UNPIVOT
(
MONTH_AMT FOR DATAMONTH IN (AMT_M1,AMT_M2,AMT_M3,AMT_M4,AMT_M5,AMT_M6,AMT_M7,AMT_M8,AMT_M9,AMT_M10,AMT_M11,AMT_M12)
) AS pv
[ASP.NET] Label & TextBox 字串轉換 => 符合列印
原因: Label才能符合列印換頁,自動換行等等
lbFILEEXP.Visible = true;
ftbFILEEXP.Visible = false;
lbFILEEXP.Text = ftbFILEEXP.Text.Replace("\r\n", "<br>"); //換行符號
lbFILEEXP.Text = lbFILEEXP.Text.Replace("\t", " ");
lbFILEEXP.Visible = true;
ftbFILEEXP.Visible = false;
lbFILEEXP.Text = ftbFILEEXP.Text.Replace("\r\n", "<br>"); //換行符號
lbFILEEXP.Text = lbFILEEXP.Text.Replace("\t", " ");
//tab表示4個空白,英文無法自動斷行
lbFILEEXP.Text = lbFILEEXP.Text.Replace(" ", " "); //1個空白,連續英文無法自動斷行
lbFILEEXP.Text = lbFILEEXP.Text.Replace(" ", " "); //1個空白,連續英文無法自動斷行
[ASP.NET]色碼表
色 碼 表
十六進位值排列
<font color="#RRGGBB">
#FFFFFF | #DDDDDD | #AAAAAA | #888888 | #666666 | #444444 | #000000 |
#FFB7DD | #FF88C2 | #FF44AA | #FF0088 | #C10066 | #A20055 | #8C0044 |
#FFCCCC | #FF8888 | #FF3333 | #FF0000 | #CC0000 | #AA0000 | #880000 |
#FFC8B4 | #FFA488 | #FF7744 | #FF5511 | #E63F00 | #C63300 | #A42D00 |
#FFDDAA | #FFBB66 | #FFAA33 | #FF8800 | #EE7700 | #CC6600 | #BB5500 |
#FFEE99 | #FFDD55 | #FFCC22 | #FFBB00 | #DDAA00 | #AA7700 | #886600 |
#FFFFBB | #FFFF77 | #FFFF33 | #FFFF00 | #EEEE00 | #BBBB00 | #888800 |
#EEFFBB | #DDFF77 | #CCFF33 | #BBFF00 | #99DD00 | #88AA00 | #668800 |
#CCFF99 | #BBFF66 | #99FF33 | #77FF00 | #66DD00 | #55AA00 | #227700 |
#99FF99 | #66FF66 | #33FF33 | #00FF00 | #00DD00 | #00AA00 | #008800 |
#BBFFEE | #77FFCC | #33FFAA | #00FF99 | #00DD77 | #00AA55 | #008844 |
#AAFFEE | #77FFEE | #33FFDD | #00FFCC | #00DDAA | #00AA88 | #008866 |
#99FFFF | #66FFFF | #33FFFF | #00FFFF | #00DDDD | #00AAAA | #008888 |
#CCEEFF | #77DDFF | #33CCFF | #00BBFF | #009FCC | #0088A8 | #007799 |
#CCDDFF | #99BBFF | #5599FF | #0066FF | #0044BB | #003C9D | #003377 |
#CCCCFF | #9999FF | #5555FF | #0000FF | #0000CC | #0000AA | #000088 |
#CCBBFF | #9F88FF | #7744FF | #5500FF | #4400CC | #2200AA | #220088 |
#D1BBFF | #B088FF | #9955FF | #7700FF | #5500DD | #4400B3 | #3A0088 |
#E8CCFF | #D28EFF | #B94FFF | #9900FF | #7700BB | #66009D | #550088 |
#F0BBFF | #E38EFF | #E93EFF | #CC00FF | #A500CC | #7A0099 | #660077 |
#FFB3FF | #FF77FF | #FF3EFF | #FF00FF | #CC00CC | #990099 | #770077 |
以色系排列
紅
顏色名稱 | 代碼 |
顏色
|
---|---|---|
maroon | #800000 | |
darkred | #8B0000 | |
brown | #A52A2A | |
firebrick | #B22222 | |
crimson | #DC143C | |
red | #FF0000 |
桃紅~紛紅
顏色名稱 | 代碼 |
顏色
|
---|---|---|
mediumvioletred | #C71585 | |
palevioletred | #D87093 | |
deeppink | #FF1493 | |
fuchsia(magenta) | #FF00FF | |
hotpink | #FF69B4 | |
pink | #FFC0CB | |
lightpink | #FFB6C1 | |
mistyrose | #FFE4E1 | |
lavenderblush | #FFF0F5 |
紫
顏色名稱 | 代碼 |
顏色
|
---|---|---|
indigo | #4B0082 | |
purple | #800080 | |
darkmagenta | #8B008B | |
darkorchid | #9932CC | |
blueviolet | #8A2BE2 | |
darkviolet | #9400D3 | |
slateblue | #6A5ACD | |
mediumpurple | #9370DB | |
mediumslateblue | #7B68EE | |
mediumorchid | #BA55D3 | |
violet | #EE82EE | |
plum | #DDA0DD | |
thistle | #D8BFD8 | |
lavender | #E6E6FA |
褐~橘~米白
顏色名稱 | 代碼 |
顏色
|
---|---|---|
saddlebrown | #8B4513 | |
sienna | #A0522D | |
chocolate | #D2691E | |
indianred | #CD5C5C | |
rosybrown | #BC8F8F | |
lightcorol | #F08080 | |
salmon | #FA8072 | |
lightsalmon | #FFA07A | |
orangered | #FF4500 | |
tomato | #FF6347 | |
coral | #FF7F50 | |
darkorange | #FF8C00 | |
sandybrown | #F4A460 | |
peru | #CD853F | |
tan | #D2B48C | |
burlywood | #DEB887 | |
wheat | #F5DEB3 | |
moccasin | #FFE4B5 | |
navajowhite | #FFDEAD | |
peachpuff | #FFDAB9 | |
bisque | #FFE4C4 | |
antuquewhite | #FAEBD7 | |
papayawhip | #FFEFD5 | |
cornsilk | #FFF8DC | |
oldlace | #FDF5E6 | |
linen | #FAF0E6 | |
seashell | #FFF5EE | |
snow | #FFFAFA | |
floralwhite | #FFFAF0 | |
ivory | #FFFFF0 | |
mintcream | #F5FFFA |
金~黃
顏色名稱 | 代碼 |
顏色
|
---|---|---|
darkgoldenrod | #B8860B | |
goldenrod | #DAA520 | |
gold | #FFD700 | |
yellow | #FFFF00 | |
darkkhaki | #BDB76B | |
khaki | #F0E68C | |
palegoldenrod | #EEE8AA | |
beige | #F5F5DC | |
lemonchiffon | #FFFACD | |
lightgoldenrodyellow | #FAFAD2 | |
lightyellow | #FFFFE0 |
綠
顏色名稱 | 代碼 |
顏色
|
---|---|---|
darkslategray | #2F4F4F | |
darkolivegreen | #556B2F | |
olive | #808000 | |
darkgreen | #006400 | |
forestgreen | #228B22 | |
seagreen | #2E8B57 | |
green(teal) | #008080 | |
lightseagreen | #20B2AA | |
madiumaquamarine | #66CDAA | |
mediumseagreen | #3CB371 | |
darkseagreen | #8FBC8F | |
yellowgreen | #9ACD32 | |
limegreen | #32CD32 | |
lime | #00FF00 | |
chartreuse | #7FFF00 | |
lawngreen | #7CFC00 | |
greenyellow | #ADFF2F | |
mediumspringgreen | #00FA9A | |
springgreen | #00FF7F | |
lightgreen | #90EE90 | |
palegreen | #98F898 | |
aquamarine | #7FFFD4 | |
honeydew | #F0FFF0 |
藍
顏色名稱 | 代碼 |
顏色
|
---|---|---|
midnightblue | #191970 | |
navy | #000080 | |
darkblue | #00008B | |
darkslateblue | #483D8B | |
mediumblue | #0000CD | |
royalblue | #4169E1 | |
dodgerblue | #1E90FF | |
cornflowerblue | #6495ED | |
deepskyblue | #00BFFF | |
lightskyblue | #87CEFA | |
lightsteelblue | #B0C4DE | |
lightblue | #ADD8E6 | |
steelblue | #4682B4 | |
darkcyan | #008B8B | |
cadetblue | #5F9EA0 | |
darkturquoise | #00CED1 | |
mediumturquoise | #48D1CC | |
turquoise | #40E0D0 | |
skyblue | #87CECB | |
powderblue | #B0E0E6 | |
paleturquoise | #AFEEEE | |
lightcyan | #E0FFFF | |
azure | #F0FFFF | |
aliceblue | #F0F8FF | |
aqua(cyan) | #00FFFF |
黑~灰~白
顏色名稱 | 代碼 |
顏色
|
---|---|---|
black | #000000 | |
dimgray | #696969 | |
gray | #808080 | |
slategray | #708090 | |
lightslategray | #778899 | |
darkgray | #A9A9A9 | |
silver | #C0C0C0 | |
lightgray | #D3D3D3 | |
gainsboro | #DCDCDC | |
whitesmoke | #F5F5F5 | |
ghostwhite | #F8F8FF | |
white | #FFFFFF |
以顏色名稱的字母順序排列
aliceblue | antiquewhite | aqua | aquamarine |
azure | beige | bisque | black |
blanchedalmond | blue | blueviolet | brown |
burlywood | cadetblue | chartreuse | chocolate |
coral | cornflowerblue | cornsilk | crimson |
cyan | darkblue | darkcyan | darkgoldenrod |
darkgray | darkgreen | darkkhaki | darkmagenta |
darkolivegreen | darkorange | darkorchid | darkred |
darksalmon | darkseagreen | darkslateblue | darkslategray |
darkturquoise | darkviolet | deeppink | deepskyblue |
dimgray | dodgerblue | firebrick | floralwhite |
forestgreen | fuchsia | gainsboro | ghostwhite |
gold | goldnrod | gray | green |
greenyellow | honeydew | hotpink | indianred |
indigo | ivory | khaki | lavender |
lavenderblush | lawngreen | lemonchiffon | lightblue |
lightcoral | lightcyan | lightgoldenrodyellow | lightgreen |
lightgrey | lightpink | lightsalmon | lightseagreen |
lightskyblue | lightslategray | lightsteelblue | lightyellow |
lime | limegreen | linen | magenta |
maroon | mediumaquamarine | mediumblue | mediumorchid |
mediumpurple | mediumseagreen | mediumslateblue | mediumspringgreen |
mediumturquoise | mediumvioletred | midlightblue | mintcream |
mistyrose | moccasin | navajowhite | navy |
oldlace | olive | olivedrab | orange |
orangered | orchid | palegoldenrod | palegreen |
paleturquoise | palevioletred | papaywhip | peachpuff |
peru | pink | plum | powderblue |
purple | red | rosybrown | royalblue |
saddlebrown | salmon | sandybrown | seagreen |
seashell | sienna | silver | skyblue |
slateblue | slategray | snow | springgreen |
steelblue | tan | teal | thistle |
tomato | turquoise | violet | wheat |
white | whitesmoke | yellow | yellowgreen |
[C#]gridview控制項值pageload時重新傳給DB
//fgvIFGAA10FD1不在編輯區製作的資料要重新load
ftbMTDT.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
ftbMTPGMID.Text = "IFGAA30F";
ftbMTUSERID.Text = this.Master.User.USERID;
for (int i = 0; i < fgvD80.Rows.Count; i++)
{
DataTable dt = new DataTable() ;
dt = fgvD80.TempTable;//這裡被唯讀要解決
foreach (DataColumn dc in dt.Columns)
{
dc.ReadOnly = false;
}
TextBox tbVENDORNUM2 = (TextBox)fgvD80.Rows[i].FindControl("tbVENDORNUM2");
TextBox tbVENDORPAYMODE =(TextBox)fgvD80.Rows[i].FindControl("tbVENDORPAYMODE");
TextBox tbVENDORPAYDATE = (TextBox)fgvD80.Rows[i].FindControl("tbVENDORPAYDATE");
dt.Rows[i]["VENDORNUM2"] = tbVENDORNUM2.Text.Trim();
dt.Rows[i]["VENDORAMTS"] = Convert.ToInt32(tbVENDORNUM2.Text.Trim()) * Convert.ToInt32(dt.Rows[i]["VENDORAMT"].ToString());
dt.Rows[i]["VENDORPAYMODE"] = tbVENDORPAYMODE.Text.Trim();
dt.Rows[i]["VENDORPAYDATE"] = tbVENDORPAYDATE.Text.Trim();
dt.Rows[i]["MTUSERID"] = this.Master.User.USERID;
dt.Rows[i]["MTPGMID"] = "IFGAA30F";
dt.Rows[i]["MTDT"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
//注意順序,先AcceptChanges再做DataBind
fgvD80.TempTable.AcceptChanges();
fgvD80.DataBind(fgvD80.TempTable);
ftbMTDT.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
ftbMTPGMID.Text = "IFGAA30F";
ftbMTUSERID.Text = this.Master.User.USERID;
for (int i = 0; i < fgvD80.Rows.Count; i++)
{
DataTable dt = new DataTable() ;
dt = fgvD80.TempTable;//這裡被唯讀要解決
foreach (DataColumn dc in dt.Columns)
{
dc.ReadOnly = false;
}
TextBox tbVENDORNUM2 = (TextBox)fgvD80.Rows[i].FindControl("tbVENDORNUM2");
TextBox tbVENDORPAYMODE =(TextBox)fgvD80.Rows[i].FindControl("tbVENDORPAYMODE");
TextBox tbVENDORPAYDATE = (TextBox)fgvD80.Rows[i].FindControl("tbVENDORPAYDATE");
dt.Rows[i]["VENDORNUM2"] = tbVENDORNUM2.Text.Trim();
dt.Rows[i]["VENDORAMTS"] = Convert.ToInt32(tbVENDORNUM2.Text.Trim()) * Convert.ToInt32(dt.Rows[i]["VENDORAMT"].ToString());
dt.Rows[i]["VENDORPAYMODE"] = tbVENDORPAYMODE.Text.Trim();
dt.Rows[i]["VENDORPAYDATE"] = tbVENDORPAYDATE.Text.Trim();
dt.Rows[i]["MTUSERID"] = this.Master.User.USERID;
dt.Rows[i]["MTPGMID"] = "IFGAA30F";
dt.Rows[i]["MTDT"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
//注意順序,先AcceptChanges再做DataBind
fgvD80.TempTable.AcceptChanges();
fgvD80.DataBind(fgvD80.TempTable);
[SQL]查詢重覆資料日期最大的資料
SELECT * FROM IFGAA50FD80 AS A
WHERE A.MTDT =
(SELECT MAX(MTDT) FROM IFGAA50FD80
AS B WHERE A.IFGAA50FD80002 = B.IFGAA50FD80002
)
WHERE A.MTDT =
(SELECT MAX(MTDT) FROM IFGAA50FD80
AS B WHERE A.IFGAA50FD80002 = B.IFGAA50FD80002
)
[SQL]查詢某字串是否在程式碼裡
SQL 查詢某字串是否在程式碼裡
SELECT OBJECT_NAME(object_id)
FROM sys.sql_modules
WHERE Definition LIKE '%ARCOM040_S00%'--要查的字串
-- AND OBJECTPROPERTY(object_id, 'IsProcedure') = 1
--OBJECTPROPERTY 可以指定類型
[SQL]SQL日期時間轉為字串
datetime to string format
字串轉日期
SELECT convert(datetime, '2019-09-05 20:44:11.500')
CONVERT(varchar, getdate(), 1) --mm/dd/yy
CONVERT(varchar, getdate(), 2) --yy.mm.dd
CONVERT(varchar, getdate(), 3) --dd/mm/yy
CONVERT(varchar, getdate(), 4) --dd.mm.yy
CONVERT(varchar, getdate(), 5) --dd-mm-yy
CONVERT(varchar, getdate(), 10) --mm-dd-yy
CONVERT(varchar, getdate(), 11) --yy/mm/dd
CONVERT(varchar, getdate(), 12) --yymmdd
CONVERT(varchar, getdate(), 101) --mm/dd/yyyy
CONVERT(varchar, getdate(), 102) --yyyy.mm.dd
CONVERT(varchar, getdate(), 103) --dd/mm/yyyy
CONVERT(varchar, getdate(), 104) --dd.mm.yyyy
CONVERT(varchar, getdate(), 105) --dd-mm-yyyy
CONVERT(varchar, getdate(), 110) --mm-dd-yyyy
CONVERT(varchar, getdate(), 111) --yyyy/mm/dd
CONVERT(varchar, getdate(), 112) --yyyymmdd
CONVERT(char(6), getdate(), 112) --yyyymm
CONVERT(varchar, getdate(), 120) --yyyy-mm-dd hh:MM:ss
replace(replace(replace(replace(CONVERT(varchar, getdate(), 21),' ',''),':',''),'-',''),'.','') --yyyymmddhhmmsssss
檢查是否為合法日期格式
SELECT ISDATE('2019-04-01')
--1 (int)正確
SELECT ISDATE('2019-02-33')
--0 (int)錯誤
--取得現在時間GETDATE()
select GETDATE()
--2019-04-26 16:25:31.900
--取得現在UTC時間(格林威治標準時間)GETUTCDATE()
select GETUTCDATE()
--2019-04-28 16:30:23.650
SELECT convert(datetime, '2019-09-05 20:44:11.500')
取得星期幾
DATEPART(weekday, GETDATE())
[IE相容性]瀏覽器呈現為特定的版本
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
寫在asp:Content 裡面,強制為 IE11
<%@ Page Title="" Language="C#" MasterPageFile="~/FTemplate/MasterPage.master" AutoEventWireup="true"
CodeFile="IFCMA10F.aspx.cs" Inherits="Apps_FORM_IFCMA10F_IFCMA10F" %>
<%@ MasterType VirtualPath="~/FTemplate/MasterPage.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.2.js" type="text/javascript"></script>
- 強制瀏覽器呈現為特定的版本的標準。它不支援 IE7 及以下:
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7"/>
- 如果用分號分開,它設定為不同版本的兼容級別,IE7、IE9。它允許不同層次的向後兼容性:
<meta http-equiv="X-UA-Compatible" content="IE=7; IE-9"/>
- 只選擇其中一個選項:
<meta http-equiv="X-UA-Compatible" content="IE=9">
<meta http-equiv="X-UA-Compatible" content="IE=8"/>
<meta http-equiv="X-UA-Compatible" content="IE=7">
<meta http-equiv="X-UA-Compatible" content="IE=5">
- 允許更容易的測試和維護。雖然通常比較有用的版本,這是使用模擬:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9"/>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
- 什麼版本的 IE 就用什麼版本的標準模式:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
- 使用以下程式碼強制 IE 使用 Chrome Frame(此專案已於 2014 年 2 月 25 日停止維護):
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
[SQL]字串或2進位字元被截斷
字串或2進位字元被截斷
請檢查 來源Table => 目標Table
1. insert所有欄位長度要一樣
2. 欄位順序要一樣
3. 注意 desimal 轉 int 會 error
請檢查 來源Table => 目標Table
1. insert所有欄位長度要一樣
2. 欄位順序要一樣
3. 注意 desimal 轉 int 會 error
[C#+GridviewTable]GridviewTable被設定唯讀該如何處理
if (fgvD80.Rows.Count > 0 && this.StepA != null && this.StepB != null)
{
//fgvIFGAA10FD1不在編輯區製作的資料要重新
//關卡910+001可以編輯經辦意見
if (this.StepA == "100" && this.StepB == "002")
{
ftbMTDT.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
ftbMTPGMID.Text = "IFGAA30F";
ftbMTUSERID.Text = this.Master.User.USERID;
for (int i = 0; i < fgvD80.Rows.Count; i++)
{
DataTable dt = new DataTable() ;
dt = fgvD80.TempTable;//這裡被唯讀要解決
foreach (DataColumn dc in dt.Columns)
{
dc.ReadOnly = false;
}
TextBox tbVENDORNUM = (TextBox)fgvD80.Rows[i].FindControl("tbVENDORNUM");
dt.Rows[i]["VENDORNUM2"] = tbVENDORNUM.Text.Trim();
dt.Rows[i]["MTUSERID"] = this.Master.User.USERID;
dt.Rows[i]["MTPGMID"] = "IFGAA30F";
dt.Rows[i]["MTDT"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
}
fgvD80.TempTable.AcceptChanges();
fgvD80.DataBind(fgvD80.TempTable);
}
}
{
//fgvIFGAA10FD1不在編輯區製作的資料要重新
//關卡910+001可以編輯經辦意見
if (this.StepA == "100" && this.StepB == "002")
{
ftbMTDT.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
ftbMTPGMID.Text = "IFGAA30F";
ftbMTUSERID.Text = this.Master.User.USERID;
for (int i = 0; i < fgvD80.Rows.Count; i++)
{
DataTable dt = new DataTable() ;
dt = fgvD80.TempTable;//這裡被唯讀要解決
foreach (DataColumn dc in dt.Columns)
{
dc.ReadOnly = false;
}
TextBox tbVENDORNUM = (TextBox)fgvD80.Rows[i].FindControl("tbVENDORNUM");
dt.Rows[i]["VENDORNUM2"] = tbVENDORNUM.Text.Trim();
dt.Rows[i]["MTUSERID"] = this.Master.User.USERID;
dt.Rows[i]["MTPGMID"] = "IFGAA30F";
dt.Rows[i]["MTDT"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
}
fgvD80.TempTable.AcceptChanges();
fgvD80.DataBind(fgvD80.TempTable);
}
}
[C#]下拉選單改變 TR style 的 display 狀態,並在pageload後保存
CS //此寫法是笨方法,直接在pageload再判斷一次
#region javascript改變display值需要pageload時再做一次,值會loaddefault
ScriptManager.RegisterStartupScript(Page, GetType(), "displaytr", "<script>displaytr()</script>", false);
#endregion
ASPX
<script type="text/javascript">
function displaytr() {
var displayvalue = document.getElementById('ctl00_ContentPlaceHolder1_fddlFORM').value; //下拉選單的值
var tr01 = document.getElementById('tr01');
var tr02 = document.getElementById('tr02');
var tr03 = document.getElementById('tr03');
if (displayvalue == 'Y') {
tr01.style.display = '';
tr02.style.display = '';
tr03.style.display = '';
}
else {
tr01.style.display = 'none';
tr02.style.display = 'none';
tr03.style.display = 'none';
}
}
</script>
<td id="tdFORM2" rowspan="1">
<iFlow:FDataDropDownList ID="fddlFORM" runat="server" Title="" Width="95%" ColumnName="MERGEFLAG" onchange="displaytr()">
<asp:ListItem Value="Y">是</asp:ListItem>
<asp:ListItem Value="N" Selected="True">否</asp:ListItem>
</iFlow:FDataDropDownList>
</td>
<tr id="tr01" style="display:none;">
<td colspan="6">
<asp:Label ID="Label30" runat="server" Text="採購建議廠商(請從下方表列勾選)" Width="99%" Font-Bold="True"
BackColor="#FFFF99"></asp:Label>
</td>
</tr>
<tr id="tr02" style="display:none;">
<td align="right">
建議廠商
</td>
<td align="center">
<iFlow:FDataTextBox ID="ftbVENDORNO" runat="server" Width="7%" ColumnName="VENDORNO"
Title="建議廠商序號" Font-Size="Medium" BackColor="Gainsboro" isRequired="true"></iFlow:FDataTextBox>
<iFlow:FDataTextBox ID="ftbVENDORNM" runat="server" Width="75%" ColumnName="VENDORNM"
Title="建議廠商名稱" Font-Size="Medium" BackColor="Gainsboro"></iFlow:FDataTextBox>
</td>
<td align="right">
建議總價
</td>
<td align="center">
<iFlow:FDataTextBox ID="ftbVENDORAMT" runat="server" Width="95%" ColumnName="VENDORAMT"
Title="建議廠商總價" Font-Size="Medium" BackColor="Gainsboro"></iFlow:FDataTextBox>
</td>
<td align="right">
付款方式
</td>
<td align="center">
<iFlow:FDataTextBox ID="ftbVENDORPAYMODE" runat="server" Width="95%" ColumnName="VENDORPAYMODE"
Title="付款方式" Font-Size="Medium" BackColor="Gainsboro"></iFlow:FDataTextBox>
</td>
</tr>
<tr id="tr03" style="display:none;">
<td align="right">
預定付款日
</td>
<td align="center">
<iFlow:FDataTextBox ID="ftbVENDORPAYDATE" runat="server" ColumnName="VENDORPAYDATE"
Title="預定付款日" Width="87%" Font-Size="Medium" BackColor="Gainsboro"></iFlow:FDataTextBox>
</td>
</tr>
#region javascript改變display值需要pageload時再做一次,值會loaddefault
ScriptManager.RegisterStartupScript(Page, GetType(), "displaytr", "<script>displaytr()</script>", false);
#endregion
ASPX
<script type="text/javascript">
function displaytr() {
var displayvalue = document.getElementById('ctl00_ContentPlaceHolder1_fddlFORM').value; //下拉選單的值
var tr01 = document.getElementById('tr01');
var tr02 = document.getElementById('tr02');
var tr03 = document.getElementById('tr03');
if (displayvalue == 'Y') {
tr01.style.display = '';
tr02.style.display = '';
tr03.style.display = '';
}
else {
tr01.style.display = 'none';
tr02.style.display = 'none';
tr03.style.display = 'none';
}
}
</script>
<td id="tdFORM2" rowspan="1">
<iFlow:FDataDropDownList ID="fddlFORM" runat="server" Title="" Width="95%" ColumnName="MERGEFLAG" onchange="displaytr()">
<asp:ListItem Value="Y">是</asp:ListItem>
<asp:ListItem Value="N" Selected="True">否</asp:ListItem>
</iFlow:FDataDropDownList>
</td>
<tr id="tr01" style="display:none;">
<td colspan="6">
<asp:Label ID="Label30" runat="server" Text="採購建議廠商(請從下方表列勾選)" Width="99%" Font-Bold="True"
BackColor="#FFFF99"></asp:Label>
</td>
</tr>
<tr id="tr02" style="display:none;">
<td align="right">
建議廠商
</td>
<td align="center">
<iFlow:FDataTextBox ID="ftbVENDORNO" runat="server" Width="7%" ColumnName="VENDORNO"
Title="建議廠商序號" Font-Size="Medium" BackColor="Gainsboro" isRequired="true"></iFlow:FDataTextBox>
<iFlow:FDataTextBox ID="ftbVENDORNM" runat="server" Width="75%" ColumnName="VENDORNM"
Title="建議廠商名稱" Font-Size="Medium" BackColor="Gainsboro"></iFlow:FDataTextBox>
</td>
<td align="right">
建議總價
</td>
<td align="center">
<iFlow:FDataTextBox ID="ftbVENDORAMT" runat="server" Width="95%" ColumnName="VENDORAMT"
Title="建議廠商總價" Font-Size="Medium" BackColor="Gainsboro"></iFlow:FDataTextBox>
</td>
<td align="right">
付款方式
</td>
<td align="center">
<iFlow:FDataTextBox ID="ftbVENDORPAYMODE" runat="server" Width="95%" ColumnName="VENDORPAYMODE"
Title="付款方式" Font-Size="Medium" BackColor="Gainsboro"></iFlow:FDataTextBox>
</td>
</tr>
<tr id="tr03" style="display:none;">
<td align="right">
預定付款日
</td>
<td align="center">
<iFlow:FDataTextBox ID="ftbVENDORPAYDATE" runat="server" ColumnName="VENDORPAYDATE"
Title="預定付款日" Width="87%" Font-Size="Medium" BackColor="Gainsboro"></iFlow:FDataTextBox>
</td>
</tr>
[JavaScript]檢查gridview textbox 只能輸入發票2位英文大寫+8位數字
<script type="text/javascript">
////檢查gridview textbox 只能輸入發票2位英文大寫+8位數字
function isINVNO(textControl)
{
var str = textControl.value;
if (str.length = 10)
{
var regexp = /^[a-zA-Z]{2}[0-9]{8}$/;
if (!regexp.test(textControl.value))
{
alert("發票格式不正確!");
textControl.value = "";
}
}
else
{
alert("發票格式不正確!");
textControl.value = "";
}
}
</script>
<iFlow:FDataTextBox ID="ftbCHECKINVNO" runat="server" ColumnName="CHECKINVNO" Title="發票號碼" Width="85%" onchange="isINVNO(this);">
////檢查gridview textbox 只能輸入發票2位英文大寫+8位數字
function isINVNO(textControl)
{
var str = textControl.value;
if (str.length = 10)
{
var regexp = /^[a-zA-Z]{2}[0-9]{8}$/;
if (!regexp.test(textControl.value))
{
alert("發票格式不正確!");
textControl.value = "";
}
}
else
{
alert("發票格式不正確!");
textControl.value = "";
}
}
</script>
<iFlow:FDataTextBox ID="ftbCHECKINVNO" runat="server" ColumnName="CHECKINVNO" Title="發票號碼" Width="85%" onchange="isINVNO(this);">
[JavaScript]gridview 總合傳給頁面控制項
<script type="text/javascript">
//gridview 總合傳給控制相
function getTotal(textControl) {
var tbl = document.getElementById("ctl00_ContentPlaceHolder1_fgvD80");
var totalpassNum =0 ;
var totalamtNum =0 ;
totalpassNum = parseInt(totalpassNum)
//i從1開始,因為title不用找
for (i = 1; i < tbl.rows.length; i++) {
//取得cell裡面第一個TextBox
if (Number(tbl.rows[i].cells[8].getElementsByTagName("input")[0].value))
{
totalpassNum = totalpassNum + parseInt(tbl.rows[i].cells[8].getElementsByTagName("input")[0].value);
}
//if (Number(tbl.rows[i].cells[9].getElementsByTagName("input")[0].value)) {
// totalpassNum = totalpassNum + tbl.rows[i].cells[9].getElementsByTagName("input")[0].value;
//}
}
//傳給頁面控制項
document.getElementById("ctl00_ContentPlaceHolder1_ftbCHECKNUM").value = totalpassNum;
//document.getElementById("ctl00_ContentPlaceHolder1_ftbCHECKAMT").value = totalamtNum;
}
</script>
<asp:TemplateField HeaderText="合格數量">
<ItemTemplate>
<asp:TextBox ID="tbCHECKNUM_D80" runat="server" Text='<%# Eval("CHECKNUM") %>' Width="95%" onkeypress="return IsIntText();" onchange="getTotal(this);" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
//gridview 總合傳給控制相
function getTotal(textControl) {
var tbl = document.getElementById("ctl00_ContentPlaceHolder1_fgvD80");
var totalpassNum =0 ;
var totalamtNum =0 ;
totalpassNum = parseInt(totalpassNum)
//i從1開始,因為title不用找
for (i = 1; i < tbl.rows.length; i++) {
//取得cell裡面第一個TextBox
if (Number(tbl.rows[i].cells[8].getElementsByTagName("input")[0].value))
{
totalpassNum = totalpassNum + parseInt(tbl.rows[i].cells[8].getElementsByTagName("input")[0].value);
}
//if (Number(tbl.rows[i].cells[9].getElementsByTagName("input")[0].value)) {
// totalpassNum = totalpassNum + tbl.rows[i].cells[9].getElementsByTagName("input")[0].value;
//}
}
//傳給頁面控制項
document.getElementById("ctl00_ContentPlaceHolder1_ftbCHECKNUM").value = totalpassNum;
//document.getElementById("ctl00_ContentPlaceHolder1_ftbCHECKAMT").value = totalamtNum;
}
</script>
<asp:TemplateField HeaderText="合格數量">
<ItemTemplate>
<asp:TextBox ID="tbCHECKNUM_D80" runat="server" Text='<%# Eval("CHECKNUM") %>' Width="95%" onkeypress="return IsIntText();" onchange="getTotal(this);" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
檢查gridview textbox 只能輸入數字+倒退鍵
<script type="text/javascript">
//檢查gridview textbox 只能輸入數字+倒退鍵
function IsIntText() {
var charkeycode = window.event.keyCode;
if (charkeycode > 47 && charkeycode < 58 || charkeycode == 8) {
return true;
}
return false;
}
</script>
<asp:TemplateField HeaderText="產品數量">
<ItemTemplate>
<asp:TextBox ID="tbPRODUCTNUM_D80" runat="server" Text='<%# Eval("PRODUCTNUM") %>' Width="95%" onkeypress="return IsIntText();"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
//檢查gridview textbox 只能輸入數字+倒退鍵
function IsIntText() {
var charkeycode = window.event.keyCode;
if (charkeycode > 47 && charkeycode < 58 || charkeycode == 8) {
return true;
}
return false;
}
</script>
<asp:TemplateField HeaderText="產品數量">
<ItemTemplate>
<asp:TextBox ID="tbPRODUCTNUM_D80" runat="server" Text='<%# Eval("PRODUCTNUM") %>' Width="95%" onkeypress="return IsIntText();"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
[C#-dataset]型別 ''DBNull'' 轉換為型別 ''String'' 是無效的
1. 檢查是否有該給的欄位沒有傳給DB,透過DataSet要確認為最新修改
2. 檢查傳給DatasSet的欄位,是否為null
3. 依照寫法,檢查從aspx gridview裡是否缺少欄位,卻在dataset有設定
2. 檢查傳給DatasSet的欄位,是否為null
3. 依照寫法,檢查從aspx gridview裡是否缺少欄位,卻在dataset有設定
[DataSet Bug]無法啟用條件約束。一或多個資料列的值違反非 Null、唯一或外部索引鍵條件約束
在使用TableAdapter作Query時發生
1.原因為有些資料欄位Query出來後為null值但是該欄位在dbDataSet的屬性AllowDBNull為False因此把該欄位(或乾脆把全部欄位屬性AllowDBNull改為True
2. maxLength 檢查
直接把MaxLength設成-1,表示無限大
3.使用 DataSet 開發時,請注意該 Table 的 主鍵值,是否為組合鍵。
如為組合鍵,在查詢語句中必須要將主鍵值加在 Select 語句中。
4. 檢查對應table欄位,長度是否變更,EX:5=>10
[Javascript]Gridviewe + checkbox 勾選後將值傳給其他控制項
實在查很久,自己記錄下來
JS端
<script type="text/javascript">
var ClickNum = 0;//記錄同一checkbox連續點擊次數
var PreCheckboxID = "";//記錄點擊checkbox的ID
//listId控制checkbox的範圍
//SelectRadio是點擊checkbox自己
function SelectedSingle(listId, SelectRadio) {
///判斷是否點同一個checkbox
if (PreCheckboxID == SelectRadio.id) {
ClickNumClickNum = ClickNum + 1;
}
else {
PreCheckboxID = SelectRadio.id;
ClickNum = 0;
}
//找到範圍
var GridViewtableSearchList = document.getElementById(listId);
//找到控制範圍下所有input
var objs = GridViewtableSearchList.getElementsByTagName("input");
var gv = document.getElementById("ctl00_ContentPlaceHolder1_fgvD1");
//勾選的將fgvD1值傳給主表單IFFGAA40F
//找到控制範圍下所有checkbox都改成为false
for (var i = 0; i < objs.length; i++) {
if (objs[i].type.toLowerCase() == "checkbox")
{
objs[i].checked = false;
}
}
var SelectRadioID = SelectRadio.id;
if (ClickNum % 2 != 1) {
document.getElementById(SelectRadioID).checked = true;
}
else {
document.getElementById(SelectRadioID).checked = false;
}
for (var i = 0; i < objs.length; i++) {
if (objs[i].type.toLowerCase() == "checkbox" && objs[i].checked == true)
{
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORNO").value = gv.rows[i].cells[1].innerHTML;
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORNM").value = gv.rows[i].cells[4].innerHTML;
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORAMT").value = gv.rows[i].cells[5].innerHTML;
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORPAYMODE").value = gv.rows[i].cells[7].innerHTML;
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORPAYDATE").value = gv.rows[i].cells[8].innerHTML;
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORPAYDATE").value = gv.rows[i].cells[9].innerHTML;
}
}
}
ASP端
GV
<ItemTemplate>
<asp:CheckBox ID="cbVENDORCHECK" runat="server" onclick="SelectedSingle('t1_ctl00_ContentPlaceHolder1_fgvD1',this)" Width="95%" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="VENDORCHECK" HeaderText="建議廠商" Visible="false"></asp:BoundField>
JS端
<script type="text/javascript">
var ClickNum = 0;//記錄同一checkbox連續點擊次數
var PreCheckboxID = "";//記錄點擊checkbox的ID
//listId控制checkbox的範圍
//SelectRadio是點擊checkbox自己
function SelectedSingle(listId, SelectRadio) {
///判斷是否點同一個checkbox
if (PreCheckboxID == SelectRadio.id) {
ClickNumClickNum = ClickNum + 1;
}
else {
PreCheckboxID = SelectRadio.id;
ClickNum = 0;
}
//找到範圍
var GridViewtableSearchList = document.getElementById(listId);
//找到控制範圍下所有input
var objs = GridViewtableSearchList.getElementsByTagName("input");
var gv = document.getElementById("ctl00_ContentPlaceHolder1_fgvD1");
//勾選的將fgvD1值傳給主表單IFFGAA40F
//找到控制範圍下所有checkbox都改成为false
for (var i = 0; i < objs.length; i++) {
if (objs[i].type.toLowerCase() == "checkbox")
{
objs[i].checked = false;
}
}
var SelectRadioID = SelectRadio.id;
if (ClickNum % 2 != 1) {
document.getElementById(SelectRadioID).checked = true;
}
else {
document.getElementById(SelectRadioID).checked = false;
}
for (var i = 0; i < objs.length; i++) {
if (objs[i].type.toLowerCase() == "checkbox" && objs[i].checked == true)
{
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORNO").value = gv.rows[i].cells[1].innerHTML;
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORNM").value = gv.rows[i].cells[4].innerHTML;
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORAMT").value = gv.rows[i].cells[5].innerHTML;
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORPAYMODE").value = gv.rows[i].cells[7].innerHTML;
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORPAYDATE").value = gv.rows[i].cells[8].innerHTML;
document.getElementById("ctl00_ContentPlaceHolder1_ftbVENDORPAYDATE").value = gv.rows[i].cells[9].innerHTML;
}
}
}
ASP端
GV
<ItemTemplate>
<asp:CheckBox ID="cbVENDORCHECK" runat="server" onclick="SelectedSingle('t1_ctl00_ContentPlaceHolder1_fgvD1',this)" Width="95%" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="VENDORCHECK" HeaderText="建議廠商" Visible="false"></asp:BoundField>
[Javascript] 前端使用for迴圈查找GridView
//取得GridView物件
var
tbl = document.getElementById(
"<%= GridView_ID.ClientID %>"
);
//取得Table物件
//var tbl = document.getElementById("Table_ID");
//for迴圈(GridView和Table的做法一樣)
//i從1開始,因為title不用找
for
(i = 1; i < tbl.rows.length; i++)
{
//取得第一個cell裡的值
alert(tbl.rows[i].cells[0].innerHTML);
//取得第三個cell裡面第一個TextBox or HiddenField的值
alert(tbl.rows[i].cells[2].childNodes[0].value);
//上面那行有問題
tbl.rows[i].cells[2].getElementsByTagName("input")[0].value
//取得第四個cell裡面第一個Label的值
alert(tbl.rows[i].cells[3].childNodes[0].innerText);
//取得第五個cell裡面第一個DropDownList的值
tbl.rows[1].cells[5].children[1].value;
}
訂閱:
文章 (Atom)
[DataSet Bug]無法啟用條件約束。一或多個資料列的值違反非 Null、唯一或外部索引鍵條件約束
在使用TableAdapter作Query時發生 1. 原因為有些資料欄位Query出來後為null值 但是該欄位在dbDataSet的屬性AllowDBNull為False 因此把該欄位(或乾脆把全部欄位屬性AllowDBNull改為True 2. maxLength 檢...
-
當出現此訊息,標準說明網路很多" 物件尚未實體化就呼叫它的屬性或方法 " , 以下為自己遇到的以及處理方式,作為紀錄 表示有設定的物件,可能是DataTable、Int、String、陣列、object等等,未設定值(沒有值),就直接使用 1.一般的 EX ...
-
在使用TableAdapter作Query時發生 1. 原因為有些資料欄位Query出來後為null值 但是該欄位在dbDataSet的屬性AllowDBNull為False 因此把該欄位(或乾脆把全部欄位屬性AllowDBNull改為True 2. maxLength 檢...
-
色 碼 表 十六進位值排列 <font color="#RRGGBB"> #FFFFFF #DDDDDD #AAAAAA #888888 #666666 #444444 #000000 #FFB7DD #FF88C2 #FF4...