c# - Query a Datagridview.Rows or Dataset using Linq -


i have problem. since i'm not experienced linq couldn't figure out how query datagridview (or directly dataset preferably) , show results on datagridview.

this fill full datagridview , dataset:

string icerikquery = "select * [rrselfservis].[dbo].[talimaticerikler] order [kod] asc, [percent] desc"; //messagebox.show(icerikquery);  sqldataadapter icerikadapter = new sqldataadapter(icerikquery, connection); dataset icerikset = new dataset(); icerikadapter.fill(icerikset, "test_table_icerik"); datagridview2.datasource = icerikset; datagridview2.datamember = "test_table_icerik"; 

and here query part:

datagridview4.datasource = datagridviewrow in datagridview2.rows                               rowview.row.field<string>("kod").value.tostring() == somesearchstringvariable                               orderby rowview.row.field<decimal>("percent") descending                               select row; 

but i'm having error datagridview2.rows:

could not find implementation of query pattern source type 'system.windows.forms.datagridviewrowcollection'. 'where' not found. consider explicitly specifying type of range variable 'datagridviewrow'.

my first choice query dataset icerikset datagridview work too.

thanks in advance.

take datatable dataset want search, mark enumerable , select rows matching search.

var query = row in icerikset.tables[0].asenumerable()             row.field<string>("kod").equals(somesearchstringvariable)             orderby row.field<decimal>("percent") descending             select row; 

you can create dataset or datatable query , set source grid.

datatable dt = query.copytodatatable(); [...] 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -