/// <summary> /// Gets the record associated with the specified DetailsViewDataGrid. /// </summary> /// <param name="dataGrid"> /// The SfDataGrid. /// </param> /// <param name="detailsViewDataGrid"> /// Specifies the DetailsViewDataGrid to get its corresponding record entry. /// </param> /// <returns> /// The record associated with the specified DetailsViewDataGrid; returns null, if the DetailsViewDataGrid is null. /// </returns> public static object GetGridDetailsViewRecord(this SfDataGrid dataGrid, DetailsViewDataGrid detailsViewDataGrid) { if (detailsViewDataGrid == null || dataGrid.View == null) { return(null); } var index = dataGrid.GetGridDetailsViewRowIndex(detailsViewDataGrid); if (index == -1) { return(null); } RecordEntry record = null; if (dataGrid.GridModel.HasGroup) { var recordIndex = dataGrid.ResolveToGroupRecordIndexForDetailsView(index); record = dataGrid.View.TopLevelGroup.DisplayElements[recordIndex] as RecordEntry; } else { var recordIndex = dataGrid.ResolveToRecordIndex(index); record = dataGrid.View.Records[recordIndex]; } return(record); }