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

How to verify childTable value of the new record added in parentTable

Hello,

I have tables of master-detail type relationship: ParentTable is "Currency", ChildTable is "Rate".

if user put a new record in "Currency" how to verify if this user had been entered at least one record for "Rate" of this new "Currency" name?
Before the user click "Save" button, we expect that it reject to save the "Currency" table if there is no rate value entered in "Rate" table. We expect no new Currency name being saved without any rate value set in childtable.
How to perfecly code it for btnSave_click event?

Thanks for your assist!
Harry


1 Reply

AD Administrator Syncfusion Team March 28, 2008 09:53 PM UTC

Hi Harry,

Thanks for using Syncfusion products.

You can validate the data before insert into the grid by using "CurrentRecordContextChange" event. Please refer the below given code snippet:


private void gridGroupingControl1_CurrentRecordContextChange(object sender, CurrentRecordContextChangeEventArgs e)
{
if (e.Action == CurrentRecordAction.EndEditCalled && e.Record.Kind == DisplayElementKind.AddNewRecord)
{
Record rec = e.Record.GetRecord();
//You can validate this data.
if (((e.Record.GetRecord().GetValue("Rate") == null) || (e.Record.GetRecord().GetValue("Rate").ToString().Length == 0)))
{
MessageBox.Show("Invalid data");
e.Cancel = true;
}
}
}


Please let me know if you have any questions.

Best regards,
Haneef


Loader.
Live Chat Icon For mobile
Up arrow icon