We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

filter for grid

I'm using this code to filter data...
In comment area I would like to fill grid with filtered data. How?

string sFilter ="";
DataRow[] afrows = db.dataSetKolekcija.Akcioni.Select("Naziv LIKE '" + filter + "%'" );

if (afrows.Length != 0)
{
foreach (DataSetKolekcija.AkcioniRow arow in
afrows)
{
sFilter += arow;
// Here I would like to filter and fill grid...
}
}

5 Replies

AD Administrator Syncfusion Team April 17, 2007 06:11 PM UTC

What grid do you want to use?

GridControl, GridDataBoundGrid, or GridGroupingControl?

Here is some code for a GridGroupingControl.

DataRow[] drs = dt.Select("[Col1] = 5");


DataTable newtable = new DataTable();
int c = 0;
foreach (object o in drs[0].ItemArray)
{
newtable.Columns.Add(new DataColumn(string.Format("col{0}", c++), o.GetType()));
}
foreach(DataRow dr in drs)
{
newtable.Rows.Add(dr.ItemArray);
}
this.gridGroupingControl1.DataSource = newtable;


HV Hrvoje Voda April 20, 2007 10:29 PM UTC

This code is not good for me.
I'm using GridDataBoundGrid.


AD Administrator Syncfusion Team April 20, 2007 11:23 PM UTC

In the code above, changing

this.gridGroupingControl1.DataSource = newtable;

to

this.gridDataboundGrid1.DataSource = newtable;

should put the rows into a GridDataBoundGrid.


HV Hrvoje Voda April 21, 2007 09:49 AM UTC

I'm using it like that, but I get a grid with one empty row. No results.


AD Administrator Syncfusion Team April 22, 2007 08:51 PM UTC

Here is a sample showing transferring a DataRow[] into a DataTable and setting it as the DataSource of a GridDataBoundGrid. What are you doing differently?

WindowsApplication1450.zip

Loader.
Live Chat Icon For mobile
Up arrow icon