Re: Binding DateTimePicker



Hi,

"John Stivenson" <JohnStivenson@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:A8617AA3-F6BD-4E37-A34C-5C73633CFB04@xxxxxxxxxxxxxxxx
A DateTimePicker control on my form is bound to a datetime field in a
DataTable.
When inserting a new record the default value for DateTimePicker is
today's
date.
However, unless the user changes this date it is not saved to database
(NULL
is stored instead of today's date). Text fields are stored normally.

A TextBox control has similar behavior: if the user leaves
a text box blank, NULL is sent to database, but if he enters
some text and then deletes it, an empty string is stored.
It seems that there is some "Modified" property for every control.

That right, well it's the Binding that has a (private) modified flag which
is triggered by the Control property-Changed event (eg.
TextChanged/ValueChanged). The value isn't persisted if the modified flag
hasn't been set.


In this case I want to store the current date instead of NULL.
How can I achive this?

Try to set default values on the DataSource.

If you're using NET2.0 you can use the DataTable.TableNewRow event.

HTH,
Greetings







.



Relevant Pages

  • Re: ASP.NET controls help!!!
    ... Only fill in the values of the database if Page.IsPostback is false. ... Eran Kampf ... > containt some values in these controls, but if the user changes the values ... > the control, it still have the original value. ...
    (microsoft.public.dotnet.languages.csharp)
  • ASP.NET controls help!!!
    ... I have an asp.net page and in the Page_Load event I connect to a database ... and put results in some TextBox controls to,when the user see the page, it ... containt some values in these controls, but if the user changes the values on ... the control, it still have the original value. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Global datasets
    ... Sticking with the first method again. ... Populate my DataSet from the Database ... Create another control object instance ... re-instantiating it. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: instant Lisp web application publishing
    ... flow of control (e,g. first log in the user, then show page x, than ... of Lisp if they want) ... flexible database that can be easily mapped into OOP terminology (so you ... Also I don't have a good candidate server to deploy it too. ...
    (comp.lang.lisp)
  • Re: Communication Log
    ... May I send you copy of the database that I made? ... a communication log in the database so that it will store the Date, ... ContactMethodID ... The above controls are set up in a page using te tab control. ...
    (microsoft.public.access.tablesdbdesign)