WebGrid Community Server

Welcome to WebGrid Community Server Sign in | Join | Help
in Search

today's date default in Date field

Last post 09-16-2008, 20:14 by jh-hamptonpark. 4 replies.
Sort Posts: Previous Next
  •  08-08-2008, 23:21 722

    today's date default in Date field

    I'd like to have the current date automatically populate a date field when adding a new record.  Is this possible whithout having to use the date picker? 
  •  08-11-2008, 18:16 726 in reply to 722

    Re: today's date default in Date field

    Try to use the 'Value' property to populate the input field for new records.

    Olav Botterli, WebGrid Founding Developer
  •  08-16-2008, 19:11 737 in reply to 726

    Re: today's date default in Date field

    what would i put in the value property to show the current date automatically?  Thanks
  •  08-18-2008, 16:25 738 in reply to 737

    Re: today's date default in Date field

    I've done something like this by implementing the "NewRecordClick" event.  Within that event handler, I put the following lines of code:

    // "pageGrid" is the ID of my grid
    string dateUpdated = DateTime.Now.ToString(pageGrid.DefaultDateTimeFormat);
    pageGrid.Columns["ColumnID"].Value = dateUpdated;



  •  09-16-2008, 20:14 788 in reply to 737

    Re: today's date default in Date field

    i found this to work - if anyone is interested: 

    value=GETDATE()

    <WG:DateTime Format="MM/dd/yyyy" ColumnId="Date" AllowEmpty="False" EditAlign="Left" GridAlign="Left" IsInDataSource="True" Priority="40" DisplayCalendar="false" Title="Today's Date" value=GETDATE() Visibility="Edit"></WG:DateTime>

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems