Windows 窗体上的 SubSonic 和 dateTimePicker 控件
问题#1:最新工作版本
我目前使用的是 SubSonic 2.1built 491。 还有后期建设吗? 我在哪里可以得到它? 我知道 2.2 已发布,但它没有附带安装程序,我不知道如何修改 App.Config/Web.Config 来使用它。
问题 #2:Windows 窗体上的 dateTimePicker 控件存在问题。
我不断收到 System.FormatException
尝试从 SubSonic 检索数据到该控件或通过 SubSonic 将数据从该控件保存到数据库。
例如,如果我只想保存时间,我可以使用 .Text 属性。 要保存日期,我需要使用控件的 .Value 属性。
我尝试了各种转换,例如 Convert.ToDateTime(dateTimePicker.Value.ToString())
等,但我找不到不会引发异常的一致模式。 对此的任何帮助将不胜感激。
Question #1: Latest working Version
I'm currently using SubSonic 2.1 built 491.
Is there a later build? Where can I get it?
I know 2.2 was released but it doesn't come with a Setup and I wouldn't know how to modify the App.Config/Web.Config to work with it.
Question #2: Issue with dateTimePicker control on Windows Form.
I keep getting System.FormatException
trying to retrieve data From SubSonic to that control or saving data from that control to the Database through SubSonic.
For example, if I want to save the Time only, I can use the .Text property. To save the Date, I need to use the .Value property of the control.
I've tried all sorts of conversion such as Convert.ToDateTime(dateTimePicker.Value.ToString())
and others but I can't find a consistent pattern that would not throw an exception. Any help on this would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关于问题 1 - 我认为 SS2.1 和 2.2 之间不需要任何 app.config / web.config 更改
对于问题 2 - 您是否有机会使用 MSSQL2008 中的新数据类型? 如果是这样,SS2.2 似乎还不能正确处理它们。
Re Question 1 - I don't think any app.config / web.config change is required between SS2.1 and 2.2
For Question 2 - are you using the new data types in MSSQL2008 by any chance? If so, SS2.2 doesn't seem to handle them properly yet.
刚刚偶然发现了你的帖子。
我不确定这是否是 FormatException,但我也遇到了数据绑定 DateTimePicker 的异常。
问题是,
虽然
So 如果将属性绑定到返回早于 #1/1/1753# 或晚于 #12/31/9998# ( DateTimePicker.MaximumDateTime ) 的 DateTime 值的 DataGridView,则会出现异常。
我用我自己继承的 DateTimePicker 解决了这个问题(抱歉,但它是用 vb 编写的)
要使用它,您只需将 Subsonic 对象绑定到 value 属性即可。 但是您必须将 ShowCheckBox 属性设置为 true 并将布尔值绑定到 CheckedValue 属性(以指示日期已设置),该属性也保留在您的数据库中。
Now 如果返回空日期,则日期设置为 Now,checkedValue 设置为 false,从而导致 DateTimePicker 被禁用。
如果您选中复选框或使用日历选择日期,则复选框将设置为 true,并且复选框将被选中。
注意:不要直接绑定Checked属性,而是绑定CheckedValue属性。
Just stumbled upon your post.
I'm not sure if It was a FormatException, but I got a Exception with a databound DateTimePicker, too.
The problem is that
while
So if bind a property to a DataGridView that returns a DateTime value earlier than #1/1/1753# or later then #12/31/9998# ( DateTimePicker.MaximumDateTime ) you get an exception.
I solved this with my own inherited DateTimePicker (sorry, but it's written in vb)
To use it you can just bind your Subsonic object to the value property. But you have to set the ShowCheckBox property to true and bind a bool value to the CheckedValue property (to indicate that the date is set) which is persisted in your db, too.
Now If an empty date is returned, the date is set to Now and the checkedValue to false, leading to a disabled DateTimePicker.
If you check the Checkbox or choose a date with the calender) the checkbox is set to true and the Checkbox is checked.
Attention: Do not bind the Checked property directly, bind the CheckedValue property.