在一次綁定DataGrid的過程中,由於數據庫的值爲null,綁定到DataGrid中顯示爲空,當我在 後臺用以下語句執行時,發現取的值並不爲空:
if(temp == string.Empty)
{
//未輸出值
}
if(temp.Length == 0)
{
//也未輸出值
}
Response.write(temp); //顯示空
Response.write(temp.Length); //顯示6
原來在DataGrid綁定的時候,自動添加了一個【 】的空格符,取值的時候替換掉,得temp == string.Empty.