forgottensoul
Member
- Joined
- Nov 16, 2004
- Messages
- 17
I have created a view using the DefaultView.Sort property. If I bind this data to a data grid I can see the data is sorted. If I loop through each of the rows, the rows are not sorted.
Is there a way to sort the DataView so that the rows are sorted?
C# code
The rows returned in the loop are not sorted. The datagrid on my forum is. Any ideas on how to get a loop through the rows that would be sorted?
Thank you,
Is there a way to sort the DataView so that the rows are sorted?
C# code
Code:
DataView tmp = myData.Tables["ATable"].DefaultView;
tmp.Sort = "SomeColumn";
dataGridView1.DataSource = tmp.Table;
// Loop through each row in the tmp var. They are not sorted,
// but the data grid is.
foreach (DataRow currentRow in tmp.Table.Rows)
{
string rowCol1 = currentRow[1].ToString();
}
The rows returned in the loop are not sorted. The datagrid on my forum is. Any ideas on how to get a loop through the rows that would be sorted?
Thank you,