473,382 Members | 1,615 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,382 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 7089
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: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.