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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:42:58+00:00 2026-05-14T15:42:58+00:00

I have datatable and I am displaying those values in the datagridview with the

  • 0

I have datatable and I am displaying those values in the datagridview with the helping of code :

   dataGridView1.ColumnCount = TableWithOnlyFixedColumns.Columns.Count;
   dataGridView1.RowCount = TableWithOnlyFixedColumns.Rows.Count;
   for (int i = 0; i < dataGridView1.RowCount; i++)
   {
       for (int j = 0; j < dataGridView1.ColumnCount; j++)
       {
           dataGridView1[j, i].Value = TableWithOnlyFixedColumns.Rows[i][j].ToString();
       }
   }
   TableExtractedFromFile.Clear();
   TableWithOnlyFixedColumns.Clear();

Now I want to save the records in the datatable in csv file.How can I do that ?

  • 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-14T15:42:58+00:00Added an answer on May 14, 2026 at 3:42 pm

    You could do this:

    // we'll use these to check for rows with nulls
    var columns = yourTable.Columns
        .Cast<DataColumn>();
    
    // say the column you want to sort by is called "Date"
    var rows = yourTable.Select("", "Date ASC"); // or "Date DESC"
    
    using (var writer = new StreamWriter(yourPath)) {
        for (int i = 0; i < rows.Length; i++) {
            DataRow row = rows[i];
    
            // check for any null cells
            if (columns.Any(column => row.IsNull(column)))
                continue;
    
            string[] textCells = row.ItemArray
                .Select(cell => cell.ToString()) // may need to pick a text qualifier here
                .ToArray();
    
            // check for non-null but EMPTY cells
            if (textCells.Any(text => string.IsNullOrEmpty(text)))
                continue;
    
            writer.WriteLine(string.Join(",", textCells));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a datatable with few rows each row has few columns. I want
I have a DataTable with 10 rows say one of the columns numbered 1
In C#/ASP.NET 3.5, I have a DataTable which pulls rows from the database. I
I have a datatable AVT of type AvailDataTable. The following code works to create
I have some DataGridViews each displaying one DataTable from a DataSet with multiple DataTables.
I have DataTable which feeds a dropdown list. The values of this dropdown persist
I displaying multiple p:datatable 's through ui:repeat , the following code snippet illustrates what
I have a datatable where the columns names are getting added at runtime How
I have a DataTable, say pdt, in my code. I just want to select
I have a datatable where the rows are dynamic and each row contain a

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.