Hai sir,
I have a datatable in for (int i=0;i<5;i++)
{
o/p will be stored in datatable dt.
and i=1;
When i am storing the data in the datatble the previously saved values are replaced the new values.I want both values.
}
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Rishikesh Kumar SinghPosted Jan 31, 2013, 11:35 PM
DataTable table = new DataTable();
// Declare DataColumn and DataRow variables.
DataColumn column;
DataRow row;
// Create new DataColumn, set DataType, ColumnName
// and add to DataTable.
column = new DataColumn();
column.DataType = System.Type.GetType("System.Int32");
column.ColumnName = "id"; table.Columns.Add(column);
// similarly you can add another column
// Create new DataRow objects and add to DataTable.
for(int i = 0; i < 10; i++)
{
row = table.NewRow(); row["id"] = i;
table.Rows.Add(row);
}
In this way you can do this....
Please mark it as an accepted answer if your problem gets solved..otherwise let me know..