473,398 Members | 2,812 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,398 software developers and data experts.

How to Insert New Row Into DataTable or TableRow

Same as subject !
Nov 16 '05 #1
2 20699
....
DataRow myDataRow = myDataTable.NewRow();
myDataRow[0]=.....;
myDataRow[1]=.....;
myDataRow[2]=.....;
myDataRow[3]=.....;
....
myDataTable.Rows.Add(myDataRow);
....
Nov 16 '05 #2
I don't know why I can't Insert Bank Row Into DataTable Between Rows.
Please comment below sources code. Thanks

DataRow dr = myTable.NewRow();

for (i=0; i > myTable.Rows.Count; i++)
{
if (myOrderNo != myTable.Rows[5].ToString())
{

mySubTotal = Convert.ToDouble(myTotalPrice) * (100 -
Convert.ToDouble (myTable.Rows[7])) / 100;

dr["CustNo"] = "Sub Total : ";
dr["TotalPrice"] = mySubTotal;

myTable.Rows.Add(dr);

myGrandTotal = myGrandTotal + Convert.ToDouble(mySubTotal);

myOrderNo = myTable.Rows[5].ToString();

mySubTotal = 0;
myTotalPrice = 0;

}
else
{
myTotalPrice = myTotalPrice + Convert.ToDouble(myTable.Rows[17])
;
}
}

It is out of my expectation result.

Order No Description Item Total
11111111 XXXXXXX A 100
11111111 XXXXXXX B 200
SubTotal 300

22222222 XXXXXXX A 300
22222222 XXXXXXX B 200
SubTotal 500

Grand Total 800
dr["CustNo"] = "Grand Total : ";

dr["TotalPrice"] = myGrandTotal;

myTable.Rows.Add(dr);

"curllion" <cu******@163.com> wrote in message news:<eR**************@TK2MSFTNGP09.phx.gbl>...
...
DataRow myDataRow = myDataTable.NewRow();
myDataRow[0]=.....;
myDataRow[1]=.....;
myDataRow[2]=.....;
myDataRow[3]=.....;
...
myDataTable.Rows.Add(myDataRow);
...

Nov 16 '05 #3

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

Similar topics

2
by: George Durzi | last post by:
Consider this pseudo HTML from a web form <asp:Table> <asp:TableRow> <asp:TableCell> <asp:Table> <asp:TableRow> <asp:TableCell></asp:TableCell> <asp:TableCell></asp:TableCell>...
6
by: hb | last post by:
Hi, I have a page bill.aspx and its code-behind bill.aspx.cs. On bill.aspx I have: === Select a month: <asp:dropdownlist runat="server" id="lstDate" autopostback="True" /> <br> <asp:table...
1
by: Dazz | last post by:
Hello I have made a small app to query a database which works fine. I am now adding a logging function which writes back to the database in a separate table. When I update the OleDataAdapter,...
3
by: Ed | last post by:
Hi, I want to load data to a table in Sql Server from a dataset table in my vb.net app using a dataAdapter. I know how to do this as follows (my question is to see if I can reduce the amount...
6
by: Marcel Hug | last post by:
Hi all ! I have a table in my database, which has 3 attributes. IDFailureControl, ControlDate and ControlVersion. In the following function I test, if the date of today allready exists. Then I...
1
by: Dave | last post by:
I have a table with 3 fields of which the primary key is a autonumber. I have created my dataadapter, dataset and datagridview using a wizard. However, in the datagrid, the update and delete...
5
by: gregarican | last post by:
I have a simple VC# form that validates its text boxes' contents and I want to insert these text box contents into an SQL Server 2005 Express DB. I have added the DB as a data source but right off...
1
by: creamy | last post by:
Hi Guys, There is the access DB, and the SQL server. I'm building an application that can insert a new person, and details, into a DB. (simple stuff?!) i'm however using a typed dataset created in...
7
by: anu b | last post by:
Hi I need to use Clr trigger for insert command My code is as below I am using SQL server 2005 and VS 2008.... but after running this code i didnt get the result as i expexted it shows the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.