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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:50:10+00:00 2026-06-15T14:50:10+00:00

I have a datatable and would like to know if its possible for me

  • 0

I have a datatable and would like to know if its possible for me to select certain columns and input the data on a table. the columns are set out as below

|col1 |col2 |col3|col4 |col5 |col6|col7 |col8 |col9 |col10 |col11 |

I want to select column col1, col2 col6, col7,col3. and dispay the data in a gridview of the rows within the datatable.. currently the code that i am using is below and onmly selects certain data. I am not selecting the data from sql its data being selected from another excel which is stored in a datatable.. but i am in need of the other columns in another area as well.. this data is being written into a table in word

 for (int i = 1; i < table.Rows.Count; i++)
            {
                for (int j = 0; j < table.Columns.Count; j++)
                {
                    if (j == 0)
                    {
                        val = filteredData.Rows[row][col].ToString();
                    }
                    else
                    {
                        val = filteredData.Rows[row][col].ToString();

                        if (val == "-" || val == "")
                        {
                            val = filteredData.Rows[row][col].ToString();

                        }
                        else
                        {
                            val = Convert.ToString(Math.Round(Convert.ToDouble(filteredData.Rows[row][col]), MidpointRounding.AwayFromZero));

                        }
                    }

                    table[j, i].TextFrame.Text = val;
                    col++;
                }
  • 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-15T14:50:11+00:00Added an answer on June 15, 2026 at 2:50 pm

    First store the table in a view, then select columns from that view into a new table.

    // Create a table with abitrary columns for use with the example
    System.Data.DataTable table = new System.Data.DataTable();
    for (int i = 1; i <= 11; i++)
        table.Columns.Add("col" + i.ToString());
    
    // Load the table with contrived data
    for (int i = 0; i < 100; i++)
    {
        System.Data.DataRow row = table.NewRow();
        for (int j = 0; j < 11; j++)
            row[j] = i.ToString() + ", " + j.ToString();
        table.Rows.Add(row);
    }
    
    // Create the DataView of the DataTable
    System.Data.DataView view = new System.Data.DataView(table);
    // Create a new DataTable from the DataView with just the columns desired - and in the order desired
    System.Data.DataTable selected = view.ToTable("Selected", false, "col1", "col2", "col6", "col7", "col3");
    

    Used the sample data to test this method I found:
    Create ADO.NET DataView showing only selected Columns

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

Sidebar

Related Questions

I have a ListView and a DataTable and I would like to know how
Hello I have a datatable that I would like to filter with a single
I have a Datatable in my C# program that I would like to INSERT
Possible Duplicate: Should I Dispose() DataSet and DataTable? OP comment: I would like to
I have a large table, each row has 6 columns. Each row looks like
I have an excel spreadsheet that has 8 connections. I would like to know
I would like to normalize data in a DataTable insertRows without a key. To
Is it possible to apply a certain filter to only one datatable? I have
I have a table created from jquery datatable which displays like above: like you
I have datatable with column name tag and 100 rows of data.I need to

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.