We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How do I prefill a DataGrid cell with the current date/time

I have seen code that suggests setting the Default property of the DataColumn in the corresponding DataTable to DateTime.Now. This solution uses the date/time at the moment of that call. How do I insert the "real" current date/time? Is it possible to run "code" to supply a value? I have the column set as readonly, and as part of the primary key. I have not been able to find another way to fill the field when a new row is to be added in the DataGrid. Is there an event that is triggered when a new row is to be added, and can I add a handler? Thanks.

Loader.
Live Chat Icon For mobile
Up arrow icon