How do I loop through a datagrid which contrains 10000s of rows of data and copy and paste say for example every 10th row in a new table using a loop?
The reason why I want to do this is because I have a MS SQL database of stock market price data, every row contrains price data for that minute, see example below,
Date, Time, Open, High, Low, Close, Up Volume, Down Volume,
12/07/1993,1303,2183.00,2183.00,2183.00,2183.00,0,1
12/07/1993,1304,2183.00,2183.00,2183.00,2183.00,0,2
12/07/1993,1305,2183.50,2183.50,2183.50,2183.50,5,0
12/07/1993,1306,2183.00,2183.50,2183.00,2183.50,2,1
12/07/1993,1308,2183.50,2183.50,2183.50,2183.50,1,0
12/07/1993,1310,2183.50,2183.50,2183.50,2183.50,2,0
I am trying to create 5 more tables to show 1 minute data, 5 min data, 10 min data 15 min data, 30 min data and 1 hour data all using my original 1 minute data as the foundation for creating these new tables. (Thats why I wanted to copy and paste say every 5th row for 5min datatable, every 10th row for 10min datatable etc)
How do I do this please?
Loading
Mohamed OmarPosted Aug 10, 2009, 9:34 AM
DataTable table = // From your datasource
DataTable table1 = new DataTable();
for (int i = 0; i < table.Rows.Count; i++)
{
if (i % 10 == 0)
{
table1.ImportRow(table.Rows[i]);
}
}