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

Auto populate fields when adding a new record

when the user enters the * line on the GridGroupingControl to add a new record I would like to populate some of the fields in the new record from other controls on the form, what would be the best way to do this?


5 Replies

SN Sridhar N Syncfusion Team September 14, 2011 10:17 AM UTC

Hi Graham,

Thanks for your interest in Syncfusion products.

Your requirement can be achieved by handling the CurrentRecordContextChange event and set the record value to be edited. Please refer the below code snippet.

[ASPX]

DataSourceCachingMode="ViewState" TableLayoutMode="Fixed" Width="500" >














[Codebehind - C#]

void GridGroupingControl1_CurrentRecordContextChange(object sender, Syncfusion.Grouping.CurrentRecordContextChangeEventArgs e)
{
if (e.Record != null)
{
if (e.Record.Kind == Syncfusion.Grouping.DisplayElementKind.AddNewRecord && e.Action == Syncfusion.Grouping.CurrentRecordAction.BeginEditComplete)
{
e.Table.AddNewRecord.SetValue("Name", this.TName.Text);
}
}
}


For your convenience, we have created sample and the same can be downloaded from the following link.

GridAddNewDefault1123578910.zip

Please let me know if you have any other questions or concerns.

Regards,
Sridhar.N




GG Graham Gardner September 14, 2011 04:31 PM UTC

Ok it updates the fields ok, and the other fields can be entered ok, however when you press return the new record is not saved to the underlying table?



GG Graham Gardner September 14, 2011 08:55 PM UTC

ok problem resolved, thanks



GG Graham Gardner September 15, 2011 01:06 AM UTC

Actually the saving data issue is still occuring. I have noticed that if I apply a filter via TableDescriptor.RecordFilters and then try to add in a new record via the * line in the grid it is then that the data does not get saved to the table, am I doing something wrong or is there a bug / feature?

e.g. functionality required:

When the page loads I want the grid to filter on todays date, i.e. displays no records. When users select * Line it adds a new entry and when you press return the entry is saved and is then shown in the grid and this is repeated for as many records as required by the user.




SN Sridhar N Syncfusion Team September 15, 2011 08:59 AM UTC

Hi Graham,

Thanks for your update.

We are sorry for inconvenience caused. We suspect that add new is not functioning properly when there is no record in the grid. However, we do not provide confidential information and patches in the general forum, so could you please create a new incident such that after confirming the issue we can fix the issue and provide you the patch.

Please let us know your concerns.

Regards,
Sridhar N


Loader.
Live Chat Icon For mobile
Up arrow icon