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

  • SEARCH
  • Home
  • 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 7779473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:38:52+00:00 2026-06-01T18:38:52+00:00

I have DataTable object with next data: Id Value 1 val1 3 val2 2

  • 0

I have DataTable object with next data:

Id Value
1   val1
3   val2
2   val3

I’m selecting one row next way:

 table.Select("Id=1");

This query gives me row

 1 val1

And next I want to take the row next to selected one, i.e. row

 3 val2

Can I do this somehow? Is it possible?
Maybe there is something like row’s position in a table, that I can use to select next row by incrementing this value?

  • 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-01T18:38:53+00:00Added an answer on June 1, 2026 at 6:38 pm

    DataTable.Rows.IndexOf() is the only thing that I can think of.

    How:

    var rows=table.Select("Id=1");
    var indexOfRow=table.Rows.IndexOf(rows[0]); //since Id only 1 match
    
    var nextRow=table.Rows[indexOfRow+1];
    

    Example:

        DataTable dt = new DataTable();
        dt.Columns.Add("ID", typeof (int));
        dt.Columns.Add("AnotherID", typeof(int));
        dt.Columns.Add("Content", typeof(string));
        dt.PrimaryKey = new[] {dt.Columns["ID"]};
    
        // Add some data
        dt.Rows.Add(1, 10, "1");
        dt.Rows.Add(2, 11, "2");
        dt.Rows.Add(3, 12, "3");
        dt.Rows.Add(4, 13, "4");
    
        var index = dt.Rows.IndexOf(dt.Rows.Find(3));
    
        // index is 2
    
        Console.WriteLine(dt.Rows[index+1]);
    

    Output in Linqpad

    DataRow
    ID 4
    AnotherID 13
    Content 4

    Hope that helps

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

Sidebar

Related Questions

I have a DataTable object that contains all the data for a Table visualization.
Importing a spreadsheet I have filled a DataTable object with that data and returns
Say i have a DataTable object with data from the database, and I need
I have a DataTable object. Every column is of type string. Using LINQ, how
I have datatable with column name tag and 100 rows of data.I need to
I have a DataTable that I manually created and loaded with data using C#.
I have a DataTable as a data source of a GridView. I'm adding a
I have a DataTable which I want to save to a SQLite Database Table.
I have a DataTable object with 5 columns returned to me by a service.
I have DataTable object and am binding it to a gridview in C#. I

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.