c# - Browsing gataGridView using entity framework -


i'm trying learn entity framework using windows forms. challenge find method displays rows contains text searchtetbox, can find nowhere. 1 thing made far code below (but guess it's not ef @ all...):

datatable datatable = datagridview1.datasource datatable; dataview dataview = new dataview(datatable);  dataview.rowfilter = string.format(combobox1.text.tostring() + " '{0}'", txtboxfind.text); datagridview1.datasource = dataview; 

this code go throug debugging no error, every time text searched - shows 0 rows result. guess that's because dgv.datasource = bindingsource , cannot convert bindingsource datatable.

any ideas how fix this? if part of ef, not linq or else, pro.

you're right - code dealing data tables, , not ef. if using ef, simple code snippet filtering collection search string, similar this:

datagridview1.datasource = yourlistofpocos.where(a => a.name == searchstring).tolist(); 

but there plenty of articles on subject, try google.


Comments