or
BindingSource bsData = new BindingSource();var listBinding = new BindingList<SaleBillDetailsDTO>(lstSBDetails);bsData.DataSource = listBinding;radGridView2.DataSource = bsData; // Allow the user to add rows((BindingList<SaleBillDetailsDTO>)bsData.List).AllowNew = true;
((BindingList<SaleBillDetailsDTO>)bsData.List).AllowRemove = true; 



Public Class ProgressDialog Public Property MessstelleItems As New List(Of tblMessstelleVerzeichnisNeue) Public Property ZahlerItems As New List(Of tblZahler) Public Property MessstellenPage As MessstellenPage Public Property ZahlerPage As ZahlerPage Private _ctx As EnergieManagementDataContext Public Sub New(ByVal ctx As EnergieManagementDataContext) ' This call is required by the designer. InitializeComponent() _ctx = ctx ' Add any initialization after the InitializeComponent() call. End Sub Protected Overrides Sub OnShown(ByVal e As EventArgs) MyBase.OnShown(e) DoWork() End Sub Private Sub DoWork() RadProgressBar.Minimum = 0 If MessstelleItems.Count > 0 Then RadProgressBar.Maximum = MessstelleItems.Count For Each item In MessstelleItems Dim index = MessstelleItems.IndexOf(item) + 1 ProgressRadLabel.Text = "Lösche Messstelle " + index.ToString() + " von " + MessstelleItems.Count.ToString() RadProgressBar.Value1 = MessstelleItems.IndexOf(item) + 1 Me.Refresh() Dim tmp As New List(Of tblMessstelleVerzeichnisNeue) tmp.Add(item) MessstellenPage.CurrentMeasuringPoints = (From p In _ctx.tblMessstelleVerzeichnisNeues.ToList() Join r In tmp On p.MessstelleVerzeichnisID Equals r.MessstelleVerzeichnisID Select p).Distinct().ToList() MessstellenPage.DeleteCurrentMeasuringPoints() Next Else End If End SubEnd ClassUsing dataContext = New EnergieManagementDataContext Dim dlo As New DataLoadOptions() dlo.LoadWith(Of tblMessstelleVerzeichnisVersion)(Function(r) r.tblMessstelleVerzeichnisZeiches) dlo.LoadWith(Of tblMessstelleVerzeichnisVersion)(Function(r) r.tblMessstelleVerzeichnisMessbereiches) dlo.LoadWith(Of tblMessstelleVerzeichnisVersion)(Function(r) r.tblMessstelleVerzeichnisStorungsbereiches) dlo.LoadWith(Of tblMessstelleVerzeichnisVersion)(Function(r) r.tblMessstelleVerzeichnisVersionZahlerKanals) dlo.LoadWith(Of tblMessstelleVerzeichnisVersion)(Function(r) r.tblMessstelleVerzeichnisVersionVerantwortliches) dlo.LoadWith(Of tblMessstelleVerzeichnisVersion)(Function(r) r.tblMessstelleVerzeichnisAreal) dlo.LoadWith(Of tblMessstelleVerzeichnisVersion)(Function(r) r.tblDokumentes) dlo.LoadWith(Of tblMessstelleVerzeichnisVersionZahlerKanal)(Function(r) r.tblZahlerKanal) dlo.LoadWith(Of tblZahlerKanal)(Function(r) r.tblZahlerVersion) dataContext.LoadOptions = dlo Dim progress As New ProgressDialog(dataContext) items = RadGridViewMessstellen.SelectedRows.Select(Function(c) CType(c.Tag, tblMessstelleVerzeichnisNeue)).ToList() progress.MessstellenPage = Me progress.MessstelleItems = items progress.ShowDialog()End Using




public class Product { public int ProductId { get; set; } public string Name { get; set; } public int CategoryId { get; set; } public virtual Category Category { get; set; } } public class Category { private readonly ObservableListSource<Product> _products = new ObservableListSource<Product>(); public int CategoryId { get; set; } public string Name { get; set; } public virtual ObservableListSource<Product> Products { get { return _products; } } } public class ProductContext : DbContext { public DbSet<Category> Categories { get; set; } public DbSet<Product> Products { get; set; } public ProductContext() : base("my conn string") { this.Configuration.AutoDetectChangesEnabled = true; }this.radGridView2.RowSourceNeeded += new Telerik.WinControls.UI.GridViewRowSourceNeededEventHandler(this.radGridView2_RowSourceNeeded); GridViewTemplate childTemplate = new GridViewTemplate(); childTemplate.HierarchyDataProvider = new GridViewEventDataProvider(childTemplate); childTemplate.DataSource = this.productsBindingSource; childTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; radGridView2.MasterTemplate.Templates.Add(childTemplate);