Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9023947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:53:11+00:00 2026-06-16T05:53:11+00:00

I currently have a datatable which is sorted by a specific column and once

  • 0

I currently have a datatable which is sorted by a specific column and once the sort has been done I would like to get rid of the rows of data which are not needed at the bottom,

For example, I have 14 rows and only need the top 10, how would I be able to delete the bottom four?

the datatable is queried from a falt file spread sheet file stored in a datatable and then i am sorting the data then only want to take the top 10 rows

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:53:12+00:00Added an answer on June 16, 2026 at 5:53 am

    You could use Linq to extract the top 10 record using Take(10) but after you have sorted the datatable

    var records = datatable.AsEnumerable().OrderBy(v => v["FieldToUseAsSortOrder"]).Take(10); 
    foreach(DataRow r in records)
    {
        // process your records in order
    }
    

    Of course this will redo the sort against your table, so it’s up to you to choose between sorting through the LinQ expression above or loop on your DefaultView rows and remove the unneeded ones

    for(int x = 10; x < datatable.DefaultView.Count; x++)
    {
        datatable.DefaultView[x].Row.Delete();
    }
    datatable.AcceptChanges();
    

    The first approach leave your datatable with all the original rows extracting only the needed one, the second approach will update your datatable removing the unneeded rows (Only in memory of course)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have rich:popupPanel which contains t:dataList under one column of t:dataTable. This dataList has
I have a datatable and would like to know if its possible for me
We currently have a quote page which lists all existing quotes that we would
I have the following datatable, which has Units information. The Units have a surface
I have a DataGridView which is bound to a DataTable that contains a column
I have a Gridview which has its datasource set to a DataTable. This has
I have to leave in a DataTable only records with dates currently not present
Currently have password protection on my main and sub directories, however I'd like to
I currently have a table of concentrations, which are linked to a table of
I currently have 4 tables. Product, Category, SubCategory, ProductSubCategory. Category has a OneToMany SubCategory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.