Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
370
Bind Ultragrid to LINQ result (and keep it editable)
posted

Hello from Germany,

databinding an UltraGrid (ugrMyData, v16)  to a DataTable in a DataSet works fine:

ugrMyData.DataSource = dstTreeBuilder.MyData;

The UltraGrid is editable and passes new and updated rows to the DataTable.

Now imagine that, instead of the whole DataTable, the Ultragrid is supposed to show a subset only. The filter predicate would be Kind of "F_Category_ID IN (5,6,7,8)", where the list of integers is generated by an existing LINQ function to "flatten" a hierachy (5 = parent, 6,7,8 = children of 6, so the grid shows "5 and its children".

At first glance, I'd code:

from d in dstTreeBuilder.MyData

join h in GetDescendants(oCurrentCategory) //returns the List<int> of the hierachy ids

on d.F_Hierarchy_ID equals h

select d

This does the job of filtering. But: this is an EnumerableRowCollection, not a DataTable. So, any new or editited row for this subset is sent to nowhere....

How can I get the "DataTable edit behaviour" for a linq-based subset of a datatable?

Thanks and regards

Martin

Parents
No Data
Reply Children