473,806 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataTable.NewRo w() 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.Ne wRow();
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.Ro ws.Add(newTimeR ow);

//put new values into variables and insert another row

newTimeRow = newDataTable.Ne wRow();
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.Ro ws.Add(newTimeR ow);

Aug 25 '06 #1
1 7133
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*****@spokan ecounty.orgwrot e in message
news:11******** *************@p 79g2000cwp.goog legroups.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.Ne wRow();
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.Ro ws.Add(newTimeR ow);

//put new values into variables and insert another row

newTimeRow = newDataTable.Ne wRow();
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.Ro ws.Add(newTimeR ow);

Aug 25 '06 #2

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

Similar topics

7
3401
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 exception when I call the NewRow method. The number of times it happens is NOT consistent (sometimes a few times out of 10,000 and sometimes 1000+ times). The app is written in VB and I am using SyncLock everywhere the table is accessed but I am sure it...
1
2581
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, accept that the x-values is mirrored. It's also possible to remove these coordinates, by a method that removes any row with negative x-values. This usually works fine a few times, mirroring and then removing. But then suddenly the NewRow statement...
1
22557
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 table. System.Data.DataTable.InsertRow(DataRow row, Int32 proposedID, Int32 pos) +319 System.Data.DataRowCollection.Add(DataRow row) +14
1
2974
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 a DataGrid, and set the PrimaryKey of the DataTable to be the first cell in the grid (which is a UserID value). I then store the DataTable in a session object, from which it is retrieved for subsequent pages. All this seems to be working fine. ...
0
3169
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 datacolumns do not trigger their expression when other columns from which the expressions are derived are updated. Below is a basic example of what I am doing. User enters values into an asp.net form and clicks a button. Retrieve dataset from...
2
1780
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 put the lines in the datatable and do some actions. Does anybody knows a faster method? The fact is: I actually only need the lines starting with "0*" and "1*".
6
14326
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 For Each drSource in MySourceDataTable drTarget =MyTargetDataTable.Rows.NewRow drTarget = drSource
1
374
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 could be causing this problem? DataTable newDataTable; DataRow newTimeRow; newTimeRow = newDataTable.NewRow(); newTimeRow = var1; newTimeRow = var2;
1
5742
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 work manually. I am looking for an automated way. Thank you, Max
0
1774
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: //=================================================================== // The table
0
9597
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10366
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10371
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.