473,413 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

DataTable.NewRow() creates additional blank row

I am having problems with my datagridview adding an extra blank row. I
allow the user to enter a row of data, and based upon business rules, I
add additional rows in the following manner. What could be causing
this problem?

DataTable newDataTable;
DataRow newTimeRow;
newTimeRow = newDataTable.NewRow();
newTimeRow[1] = var1;
newTimeRow[2] = var2;
newTimeRow[3] = var3;
newTimeRow[4] = var4;
newTimeRow[5] = var5;
newTimeRow[6] = var6;
newTimeRow[7] = var7;
newTimeRow[8] = var8;
newTimeRow[9] = var9;
newTimeRow[10] = var10;
newTimeRow[11] = var11;
newDataTable.Rows.Add(newTimeRow);

//put new values into variables and insert another row

newTimeRow = newDataTable.NewRow();
newTimeRow[1] = var1;
newTimeRow[2] = var2;
newTimeRow[3] = var3;
newTimeRow[4] = var4;
newTimeRow[5] = var5;
newTimeRow[6] = var6;
newTimeRow[7] = var7;
newTimeRow[8] = var8;
newTimeRow[9] = var9;
newTimeRow[10] = var10;
newTimeRow[11] = var11;
newDataTable.Rows.Add(newTimeRow);

Aug 25 '06 #1
1 7091
Hi,

I do not understand what you mean, you are creating two new rows.
Are you rebind the datasource to the grid?
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"jhansen" <jh*****@spokanecounty.orgwrote in message
news:11*********************@p79g2000cwp.googlegro ups.com...
>I am having problems with my datagridview adding an extra blank row. I
allow the user to enter a row of data, and based upon business rules, I
add additional rows in the following manner. What could be causing
this problem?

DataTable newDataTable;
DataRow newTimeRow;
newTimeRow = newDataTable.NewRow();
newTimeRow[1] = var1;
newTimeRow[2] = var2;
newTimeRow[3] = var3;
newTimeRow[4] = var4;
newTimeRow[5] = var5;
newTimeRow[6] = var6;
newTimeRow[7] = var7;
newTimeRow[8] = var8;
newTimeRow[9] = var9;
newTimeRow[10] = var10;
newTimeRow[11] = var11;
newDataTable.Rows.Add(newTimeRow);

//put new values into variables and insert another row

newTimeRow = newDataTable.NewRow();
newTimeRow[1] = var1;
newTimeRow[2] = var2;
newTimeRow[3] = var3;
newTimeRow[4] = var4;
newTimeRow[5] = var5;
newTimeRow[6] = var6;
newTimeRow[7] = var7;
newTimeRow[8] = var8;
newTimeRow[9] = var9;
newTimeRow[10] = var10;
newTimeRow[11] = var11;
newDataTable.Rows.Add(newTimeRow);

Aug 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jason Callas | last post by:
I have a process that manages a list of trades. Each trade is a separate row in the table. I blast the process with 10,000 new trades in order to stress test it and end up with the below listed...
1
by: Tomas R | last post by:
I have a datagrid with a dataview(created from a DataTable) bind to it. It displayes coordinates and I have a toolbarbutton that will create a set of new coordinates just like the existing ones,...
1
by: Kelvin | last post by:
Hi All, I wrote a program insert new row between rows while the datatable is looping. It display the error message. Exception Details: System.ArgumentException: This row already belongs to this...
1
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
2
by: DraguVaso | last post by:
Hi, I need a FAST way to put the content of a file in a datatable (one record for each line in the file). I have a routine for it, but it takes me too much time (2-5 seconds for each file) to...
6
by: Doug Bell | last post by:
Hi, Is there a more efficient way to append the rows of a DataTable to a second DataTable that has the same structure? Currently I am using a For Next loop: Dim drSource, drTarget as DataRow...
1
by: jhansen | last post by:
I am having problems with my datagridview adding an extra blank row. I allow the user to enter a row of data, and based upon business rules, I add additional rows in the following manner. What...
1
by: Maxwell2006 | last post by:
Hi, I am working with strongly typed datatables. What is the most efficient way to build a new DataTAble based on the result of DataTable.Select? At this point I use a foreach loop to do the...
0
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.