Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Creating new row in .NET Data table

Hi

I like to know how to create a new row in the .NET datatable . I have a save button which user will click after entering data in the datagrid . once user click on the save button a new row will generate in the data table for the information user has entered in the datagrid . The databale will save the information into the database table . How do I generate new rows in the datatable . Please show me some code

Thanks
[440 byte] By [software_develo] at [2007-11-11 7:38:04]
# 1 Re: Creating new row in .NET Data table
// Create new DataTable and DataSource objects.
DataTable myDataTable = new DataTable();
// Declare DataRow variables.
DataRow myRow;

myRow = myDataTable.NewRow();
myRow["id"] = 1;
myRow["item"] = "item 001" ;
myDataTable.Rows.Add(myRow);

More Info:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatadatatableclassnewrowtopic.asp
Sync at 2007-11-11 21:48:48 >