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 6129375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:44:07+00:00 2026-05-23T16:44:07+00:00

How Create Data Table From Top 5 or 6 row in datagridview including column

  • 0

How Create Data Table From Top 5 or 6 row in datagridview including column header also .

  • 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-05-23T16:44:08+00:00Added an answer on May 23, 2026 at 4:44 pm

    your explanation is too short. Any how, what i understand from this is that either you have a datable and you want to bind its just top 5 to 6 rows to data grid or u want to bring your data grid row to datatable with headers both can done through for each loop..

    You can get column names like this from data

    string columnName = mydatagrid.Columns[columnIndex].Name;
    

    OR you can get both rows and column using foreach loop

     foreach(DataGridColumn col in dg.Columns)
       {
         dt.columns.Add(col.HeaderText);
       }
    
     foreach(DataGridRow in dg.Rows)
     {
      if(dt.Rows.Count < 6)
      //Add data to data table
    
     }
    

    The same way you can apply with little modifications to get data from datatable

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

Sidebar

Related Questions

If I have a table column with data and create an index on this
I am trying to create a table w/ a fixed header at the top
I have a table of the form CREATE TABLE data { pk INT PRIMARY
Data table structure is: id1,id2,id3,id4,... (some other fields). I want to create summary query
Does anyone have a technique for generating SQL table create (and data insert) commands
I inherited MYSQL database that has lots of tables with data like CREATE TABLE
I have the following table and data in SQL Server 2005: create table LogEntries
I need to create an SQL query to insert some data into a table
I'm trying to create my first data mart. I am creating my dimension table
I'm using System.Data.OracleClient.OracleCommand to create a table and fill it out with some data.

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.