下面的这段代码是在cs界面里的,不知道哪里出了错,即使进了switch后sql语句里的text依然是"111FFSE"。感觉是个奇怪的问题,试了很久了。麻烦各位帮帮忙
string text = "111FFSE";
string id = ((Label)(powertb.Rows[_rowIndex].Cells[1].FindControl("idLabel"))).Text;
switch (i)
{
case "pname": text = ((TextBox)(powertb.Rows[_rowIndex].Cells[_columnIndex].FindControl("pname"))).Text.Trim(); break;
case "purl": text = ((TextBox)(powertb.Rows[_rowIndex].Cells[_columnIndex].FindControl("purl"))).Text.Trim(); break;
}
sql = "update power_tb set pname='" + text + "' where id='" + id + "'";
int r = DbHelperSQL.ExecuteSql(sql);
return r+"";
2种情况都没有匹配到吧。加一个default.
说详细点,是js中的一个函数调用了cs中的这个函数,整个函数体中就这些内容。还有,确定switch(i)匹配到了,加了default效果一样。也换过if-ifelse-else,效果一样。
你的判断条件是id吗 哪来的i