Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
535
Default Date for new rows
posted

if i add a row with a date cell how can i set the date to default to now().  there are 2 options

1: set it to now() when the user starts to add the row so it's pre-populated

2: set it to now() if the user forgets to do it.

I prefer #1

Peter

  • 469350
    Suggested Answer
    Offline posted

    howudodat said:
    1: set it to now() when the user starts to add the row so it's pre-populated

    How you do this depends on how the new rows are added. If you are adding them in code or using the AddNew buttons, then you might use the AfterRowInsert event. If you are using TemplateAddRows, then you could use the DefaultCellValue property or InitializeTemplateAddRow events.

    If your data source supports it, you might be able to set the DefaultValue on the field or column.

     

  • 4555
    posted

    Hi Peter,

    You can use the BeforeRowUpdate event of the Grid, this will be the second solution:

     private void ultraGrid1_BeforeRowUpdate(object sender, CancelableRowEventArgs e)
            {
                e.Row.Cells[index].Value = DateTime.Now;
            }

     

    Magued