【发布时间】:2011-11-15 08:03:58
【问题描述】:
我有一个类型化的数据集。我将具有绑定源的数据绑定到具有 200 个文本框、数据编辑器等的表单。一切正常,只有一个例外:
在我的数据库中,我有空的 DateTimes (DBNull.Value)。当它们绑定到 DateEdit-Control 时,我得到以下异常:
A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
A first chance exception of type 'System.Data.StrongTypingException' occurred in myTestDLL.dll
我尝试将 DataSet-Desinger 中的 NullValue-Property 更改为“引发异常”,但它不适用于 DateTime。对于其他类型,如 Integer 或 String 它工作正常。
我不知道一个好的解决方案(现在我用一些虚拟日期填充空日期并使其在 DateEdit-Control 中不可见,但这很不酷),我希望在这里找到一些帮助。
似乎很多人都遇到过同样的问题,但我没有找到解决方案:(
【问题讨论】:
标签: vb.net datetime dataset .net typed