public override IList <GridViewRowInfo> GetChildRows( GridViewRowInfo parentRow, GridViewInfo view) { IList <GridViewRowInfo> gridViewRowInfoList; IList <GridViewRowInfo> sourceCollection = gridViewRowInfoList = (IList <GridViewRowInfo>) new List <GridViewRowInfo>(64); GridViewRowSourceNeededEventArgs args = new GridViewRowSourceNeededEventArgs(parentRow, this.Template, sourceCollection); this.Template.EventDispatcher.RaiseEvent <GridViewRowSourceNeededEventArgs>(EventDispatcher.RowSourceNeeded, (object)this, args); return(sourceCollection); }
private void ExampleRadGridView_RowSourceNeeded(object sender, Telerik.WinControls.UI.GridViewRowSourceNeededEventArgs e) { if (e.ParentRow != null) { if (e.ParentRow.DataBoundItem is DataRowView rowViewData) { var _childDataTable = exampleChildTableLoad(); // Replace with call to populate a datatable from a query var _dataRows = _childDataTable.Select($"ParentId = {rowViewData["Id"]}"); foreach (DataRow row in _dataRows) { GridViewRowInfo _newRowObj = e.Template.Rows.NewRow(); _newRowObj.Cells["Id"].Value = row["Id"]; _newRowObj.Cells["SampleNumber"].Value = row["SampleNumber"]; _newRowObj.Cells["ParentId"].Value = row["ParentId"]; e.SourceCollection.Add(_newRowObj); } } } }