如何使用C#保存null datetime选择器值 [英] How to save null datetime picker value using C#

查看:62
本文介绍了如何使用C#保存null datetime选择器值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个日期时间选择器名称StartDatetimepicker。当我从datetimepicker中选择无日期时,它会在我的数据库中保存今日日期,但我想在没有选择日期时将空值保存在数据库中。任何一个帮助我的好话



我尝试了什么:



i有没有关于这个paroblem的代码。

i have one datetime picker name StartDatetimepicker . when i select No date from datetimepicker it save Today date in my database but i want when no date is selected then null value save in database . Any One Help me Thnks

What I have tried:

i have no code about this paroblem.

推荐答案

据我所知,没有DateTimePicker控件直接允许无日期选项 - 如果用户没有选择一个始终显示的日期并默认返回今天的日期。



要添加此功能,您需要添加一个标记为无日期的复选框,选中时DTP,取消选中时取消隐藏。

然后,您的代码首先检查并确定要在数据库中保存的内容。
As far as I am aware, there is no DateTimePicker control which directly allows a "no date" option - if the user does not select a date it will always display and return todays date by default.

To add this function, you'd need to add a checkbox labeled "No date" which hides the DTP when checked, and unhides it when unchecked.
Your code then checks that first and decides what to save in your DB.


这篇关于如何使用C#保存null datetime选择器值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆