Datagrid DateTimepicker column style

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Karl

    Datagrid DateTimepicker column style

    Hi, .Net experts,

    I am using DatagridDateTim epickerColumn style posted on MSDN .net class
    document in my datagrid. You can see the datagridDateTim epickerColumn style
    at


    It works fine with the datetimepicker column of current record in datagrid.
    But when I click the very last record in datagrid (which creates a record), I
    got an exception. I debuged it. It occured right after leaving Edit
    function. Can somebody tell me the reasion and how to fix it?

    Thanks,

    Karl

  • Claudio Grazioli

    #2
    Re: Datagrid DateTimepicker column style

    Hi Karl
    [color=blue]
    > I am using DatagridDateTim epickerColumn style posted on MSDN .net class
    > document in my datagrid. You can see the datagridDateTim epickerColumn style
    > at:
    > http://msdn.microsoft.com/library/de...classtopic.asp
    >
    > It works fine with the datetimepicker column of current record in datagrid.
    > But when I click the very last record in datagrid (which creates a record), I
    > got an exception. I debuged it. It occured right after leaving Edit
    > function. Can somebody tell me the reasion and how to fix it?[/color]

    The standard DateTimePicker control from .NET does not support null values.
    Its value property must always be a valid DateTime value.

    When you click on the last line in the datagrid and thus create a new
    record, what happens with your DateTime value? Is it set to DateTime.Now?
    Or is it initalized with null? If the latter, you would try to set the
    DateTimePickers value property to null and that would raise an exception.

    If that is the problem you should use a DateTimePicker control that
    supports null values like this one:


    hth
    --
    Claudio Grazioli
    Our website about our photography and travel. Enjoy our picture galleries from around the world or read our blog about travel and photography


    Comment

    Working...