Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Row Filter

Row Filter

Scheduled Pinned Locked Moved ASP.NET
tutorial
7 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anushh
    wrote on last edited by
    #1

    How to filter top 4 records from a dataset using rowfilter property in codebehind page

    M 1 Reply Last reply
    0
    • A anushh

      How to filter top 4 records from a dataset using rowfilter property in codebehind page

      M Offline
      M Offline
      Manas Bhardwaj
      wrote on last edited by
      #2

      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.

      A 1 Reply Last reply
      0
      • M Manas Bhardwaj

        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.

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        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.

        M 1 Reply Last reply
        0
        • A Abhishek Sur

          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.

          M Offline
          M Offline
          Manas Bhardwaj
          wrote on last edited by
          #4

          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.

          A 1 Reply Last reply
          0
          • M Manas Bhardwaj

            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.

            A Offline
            A Offline
            Abhishek Sur
            wrote on last edited by
            #5

            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.

            M 1 Reply Last reply
            0
            • A Abhishek Sur

              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.

              M Offline
              M Offline
              Manas Bhardwaj
              wrote on last edited by
              #6

              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.

              A 1 Reply Last reply
              0
              • M Manas Bhardwaj

                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.

                A Offline
                A Offline
                Abhishek Sur
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups