data view sort question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

in asp.net i allow the user to sort a dataview which is bound to a grid
similar to this

dvMyData.Sort = "Department, Salary DESC

This works fine

I also build a CSV file so the user can download the data. My problem occurs whe
i build the CSV file. I walk through each row using a data table and code like this

For i = 0 To dt.Rows.Count -
..

I'm puzzled why the data in the data table isn't sorted, but my grid control is. I'
missing something simple but am having trouble finding it

Thanks for any assistance
 
What is the grid bound to? I'm guessing it's the view not the table. In
the code below, you are referencing the table...if you do it with the view
instead, I think the sorted data should be correct.
 
Hi,

in asp.net i allow the user to sort a dataview which is bound to a grid.
similar to this:

dvMyData.Sort = "Department, Salary DESC"

This works fine.

I also build a CSV file so the user can download the data. My problem occurs when
i build the CSV file. I walk through each row using a data table and code like this:

For i = 0 To dt.Rows.Count - 1
...

I'm puzzled why the data in the data table isn't sorted, but my grid control is. I'm
missing something simple but am having trouble finding it.

The table is never sorted. DataView shows rows as sorted but it does not
affect table sorting.
 
Hi Nike,

Little sample a table with in the column name "b" only characters A to I
\\\
Dim dv As New DataView(dt)
dv.Sort = "b DESC"
Dim a As String = Trim(dv(0)("b").ToString)
///
The field "a" contains an I in this situation.

I hope this helps?

Cor
 
Back
Top