Row Filter
-
anushh wrote:
How to filter top 4 records from a dataset using rowfilter property in codebehind page
No, the RowFilter property was not designed to do that. It is more analogous to the WHERE clause of an SQL statement. Why dont you do it at the SQL Server itself? Anyways, you may also try to use this approach:
private DataView GetTopDataViewRows(DataView dv, Int32 n)
{
DataTable dt = dv.Table.Clone();for (int i = 0; i < n-1; i++) { if (i>= dv.Count) { break; } dt.ImportRow(dv\[i\].Row); } return new DataView(dt, dv.RowFilter, dv.Sort, dv.RowStateFilter);
}
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
anushh wrote:
How to filter top 4 records from a dataset using rowfilter property in codebehind page
No, the RowFilter property was not designed to do that. It is more analogous to the WHERE clause of an SQL statement. Why dont you do it at the SQL Server itself? Anyways, you may also try to use this approach:
private DataView GetTopDataViewRows(DataView dv, Int32 n)
{
DataTable dt = dv.Table.Clone();for (int i = 0; i < n-1; i++) { if (i>= dv.Count) { break; } dt.ImportRow(dv\[i\].Row); } return new DataView(dt, dv.RowFilter, dv.Sort, dv.RowStateFilter);
}
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
hey manas... How about
datataable.AsEnumerable().Take(n)
//where n is the no of rows from datatable. ;)Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
hey manas... How about
datataable.AsEnumerable().Take(n)
//where n is the no of rows from datatable. ;)Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
Abhishek Sur wrote:
datataable.AsEnumerable().Take(n)
This is so nice. :thumbsup: I am still living with VS 2005. I must plan to move on to the VS 2010 soon :)
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Abhishek Sur wrote:
datataable.AsEnumerable().Take(n)
This is so nice. :thumbsup: I am still living with VS 2005. I must plan to move on to the VS 2010 soon :)
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
I guess so mate. Few days back... I was in 2005 like you. But after using LINQ.. I always suggest to shift from 2005, and work in 2008. 2010 is far apart. Even I didnt have a chance to work on it.. :-D :-D Cheers. :rose:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
I guess so mate. Few days back... I was in 2005 like you. But after using LINQ.. I always suggest to shift from 2005, and work in 2008. 2010 is far apart. Even I didnt have a chance to work on it.. :-D :-D Cheers. :rose:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
Abhishek Sur wrote:
2010 is far apart
Not that far. Already started the download[^] ;)
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
-
Abhishek Sur wrote:
2010 is far apart
Not that far. Already started the download[^] ;)
Manas Bhardwaj Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
Yes Thank you for the link... Already tried the Parallel Extensions in .NET 3.5 .. Excited to see .NET 4.0 with truely multicore support in it. I have already downloaded the 2010 Beta.. Just have to start doing some tests in this 1. Hope you are also enjoying this big release too. ;) :thumbsup:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.