how to add a new row into exsiting table of DataSet

K

Konda

Hi All,

I have a problem with DataSet while adding a new row into dataset by
another dataset.
My assignment is Adding and Removeing from Two Grids. I want to add a
row into new Grid2 when i selected a row from grid1 then it should be
deleted from grid1 after added into grid2. these manipulation is only
done into dataset not in database. please give me suggest how to do it

Thanks for Advance
konda
 
N

nemtsev

DataTable.Rows return you DataRowCollection where Add() and Removes()
methods are.
See MSDN for details

Below a little sample of how to add new row

private void CreateNewDataRow()
{
// Use the MakeTable function below to create a new table.
DataTable table;
table = MakeNamesTable();

// Once a table has been created, use the
// NewRow to create a DataRow.
DataRow row;
row = table.NewRow();

// Then add the new row to the collection.
row["fName"] = "John";
row["lName"] = "Smith";
table.Rows.Add(row);

foreach(DataColumn column in table.Columns)
Console.WriteLine(column.ColumnName);
dataGrid1.DataSource=table;
}
 

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