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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:35:56+00:00 2026-05-12T10:35:56+00:00

If I have a DataTable and want to create a new row I first

  • 0

If I have a DataTable and want to create a new row I first call DataTable.NewRow() which returns a DataRow. This row then has the schema of the Table, and I can set the value of each field in the row. At this point does the Table “know” about the Row, or does that only happen after I call DataTable.Rows.Add(DataRow row)?

If I call DataTable.Rows.Add() more then once are duplicate rows created in the data table with duplicate values?

The reason I ask is I’m trying to write a recursive function that will iterate down a tree structure and populate a DataTable with values. So I have situations where rows being created for each child will have columns that have all the same values because they come from the parent.

So my idea was to pass a DataRow with the parent’s information to each child. The child would add its information and then add the row to the table. But I’m trying to figure out if I need to call DataTable.NewRow() for each child, or if new rows will be created automatically if I add the same row multiple times.

  • 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-12T10:35:56+00:00Added an answer on May 12, 2026 at 10:35 am

    No, but it’s easy to copy a row so you can get what you want (assumes the existing row is in a variable called existingRow):

    var newRow = dataTable.NewRow();
    newRow.ItemArray = existingRow.ItemArray;
    dataTable.Rows.Add(newRow);
    
    • 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 multiple excel files which I open as datatable I want to merge
I have a datagridview which im binding DataTable to. What I want do is
I have a DataTable with a Name column. I want to generate a collection
I have a DataTable that has a boolean column called [Invalid]. I need to
I have a DataTable which is bound to a GridView. I also have a
I have a datatable that has a date column, but I am stumped as
I have a datatable being built in code which can dynamically have any given
This is a multi-part question. I have a table similar to: CREATE TABLE sales_data
Let's say that I have a form which runs a stored procedure. This stored

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.