- 我有這個複選框,從一個名爲贈款的位列獲取數據。這是需要的鑄造:
- 這裏我添加布爾的鑄造來解決這個問題。
- 但是它產生一個錯誤。爲什麼?我一直在試圖弄明白,不能明白爲什麼,因爲我有使用相同的代碼和正常工作等複選框。
它說:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
嘗試鑄造''布爾值,因爲它可能是你正在處理一個空值。 – NikolaiDante
也許是它的字符串?那麼你需要使用convert類。 Convert.ToBoolean –
什麼是'讀者[ 「免費」]的值。的GetType()。Name'? –