I have a DataTable which I fill from a database and the in code behind I am trying to add 3 more rows after each row. Below is the code. But at the 6th line I get
Exception of type 'System.OutOfMemoryException' was thrown.
for (int i = 0; i < AlldaysList.Rows.Count; i++)
{
DataRow row;
row = AlldaysList.NewRow();
DataRow row1;
row1 = AlldaysList.NewRow();
DataRow row2;
row2 = AlldaysList.NewRow();
// Then add the new row to the collection.
row["scenarionid"] = DBNull.Value;
row["description"] = "";
row1["scenarionid"] = DBNull.Value;
row1["description"] = "";
row2["scenarionid"] = DBNull.Value;
row2["description"] = "";
AlldaysList.Rows.InsertAt(row, i + 1);
AlldaysList.Rows.InsertAt(row1, i + 2);
AlldaysList.Rows.InsertAt(row2, i + 3);
i++;
}