Insert New Row into Existing DataTable Big Problem .. Please help !!!

K

Kelvin

Hi,

Need I Create New DataTable ? Looping Existing Datable, and Move
Existing DataRow Into New DataRow ? If need, How to do that ? Thanks
 
R

Rajagopal Pasupuleti

you can use Clone method of DataTable

private void GetClone(DataTable myDataTable){
// Get a clone of the original DataTable.
DataTable cloneTable;
cloneTable = myDataTable.Clone();
// Insert code to work with clone of the DataTable.
}
 
K

kelvinweb

Hi rajagopal,

How to apply my code ? Please advise.

y = myTable.Rows.Count;
for (i=1; y > i ; i++ )
{
DataRow dr = myTable.NewRow();
DataRow dataRow = myTable.Rows;
if (myOrderNo != (string)dataRow["OrderNo"])
{
dr["OrderNo"] = "";
dr["TotalPrice"] = mySubTotal;
myTable.Rows.Add(dr);
myTable.AcceptChanges();
myOrderNo = (string)dataRow["OrderNo"];
}
}

DetailGrid.DataSource = myTable;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top