The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Greetings,
I have a date column in a databound grid I am setting up with the following code.
this.gridData.Model.ColStyles[5].CellType = "DropDownMonthCalendar";
this.gridData.Model.ColStyles[5].CellValue = System.DateTime.Now;
As you can see I want to default in todays date for all new rows in the grid. This is a bulk entry screen.
The odd behavior I am experiencing is the following:
- When the screen is first loaded the first row is empty with the exception of the date column(this is what I want). As soon as I type in or select another column on this row the grid makes a new row(I have the enable add new property set to true) and removes the date value from my first row(what I don''t want).
Essentially, I want this date column to default to today''s date for all new rows added, but allow the user to change it if they want.
Cheers,
JF
ADAdministrator Syncfusion Team February 6, 2005 07:52 PM UTC
Jim,
use the following code to fill the AddNew row with default values. The code will be execute the moment the user starts editing the AddNew row.
this.gridDataBoundGrid1.Binder.EditModeChanged += new EventHandler(Binder_EditModeChanged);
private void Binder_EditModeChanged(object sender, EventArgs e)
{
Syncfusion.Windows.Forms.Grid.GridModelDataBinder binder = sender as Syncfusion.Windows.Forms.Grid.GridModelDataBinder;
if (binder.IsAddNew)
{
int rowIndex = binder.CurrentRowIndex;
this.gridDataBoundGrid1.Model[rowIndex, 5].CellValue = System.DateTime.Now;
}
}
Stefan
>Greetings,
>
>I have a date column in a databound grid I am setting up with the following code.
>
>this.gridData.Model.ColStyles[5].CellType = "DropDownMonthCalendar";
> this.gridData.Model.ColStyles[5].CellValue = System.DateTime.Now;
>
>As you can see I want to default in todays date for all new rows in the grid. This is a bulk entry screen.
>
>The odd behavior I am experiencing is the following:
>- When the screen is first loaded the first row is empty with the exception of the date column(this is what I want). As soon as I type in or select another column on this row the grid makes a new row(I have the enable add new property set to true) and removes the date value from my first row(what I don''t want).
>
>Essentially, I want this date column to default to today''s date for all new rows added, but allow the user to change it if they want.
>
>Cheers,
>JF
>
>