我想在RowDataBound事件擺脫DataTable內爲當前編輯行的值: 這裏是我的代碼:RowDataBound:從dataTable獲取值!無法投類型的對象'System.DBNull爲鍵入「System.String」
string KK = (string)DataBinder.Eval(e.Row.DataItem, "Name");
if (KK == "John")
{
//execute code
}
錯誤:無法將類型爲'System.DBNull'的對象轉換爲鍵入'System.String'。在第一行(字符串KK ...)
我該如何解決這個問題?
好的是,列單元格值永遠不會爲空,因爲用戶無法編輯它們/ – 2012-04-24 13:40:44