how to add a new row into exsiting table of DataSet

  • Thread starter Thread starter Konda
  • Start date Start date
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
 
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;
}
 
Back
Top