c# - Shortest way to turn a regular IEnumerable collection into a DataView -


i'm not used working datatables , built in functionalities, rather use debug visual display feature.

i'm new wpf, , although experienced linq/ienumerable extension methods, learned datagrid, in order support editing, object assigned itemssource property must implement given interface (which not sure is, time being let's either ieditablecollectionview or ibindinglist).

since used collection manipulations via ienumerable extension methods, here how manipulate datatable, filter , project columns want:

        grdsettings.itemssource =                 _settings                 .asenumerable()                 .where(row => row["table"].tostring().equals(e.addeditems[0].tostring()))                 .select(s => new                     {                         setting = s["field"],                         description = s["description"],                         charvalue = s["charvalue"],                         numminvalue = s["minvalue"],                         nummaxvalue = s["maxvalue"]                     }); 

the problem grid not editable. if assign _settings.asdataview(), grid editable. problem not want columns, , cannot make (i not know how) ienumerable dataview. read posts filtering columns datatable/dataview, solutions bit awkward, not smooth like...

isn't there small piece missing can "plug" solution, instead of having give ienumerable extension methods filtering... ?


update: mike eason below suggested replacing anonymous type predefined one, stating anonymous types read , reason why grid's collection source not support editing.

here's update typed object, still not work. not make sense think alone make work, based on premise stated above, in order grid allow editing collection source object must implement given interface that.

        grdsettings.itemssource =                 _settings                 .asenumerable()                 .where(row => row["table"].tostring().equals(e.addeditems[0].tostring()))                 .select(s => new gridrecord                     {                         setting = s["field"].tostring(),                         description = s["description"].tostring(),                         charvalue = s["charvalue"].tostring(),                         numminvalue = s["minvalue"].tostring(),                         nummaxvalue = s["maxvalue"].tostring()                     }); 

in absence of better solutions, made use of datatableproxy nuget package, make datatable out of regular ienumerable<t>, dropped datatable code, , used list<list<string>> instead (because not want create 2nd instance of datatable sake of editing grid) - making datatable out of using package.

i have editable grid, still optimistic simpler solutions :-)


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -