Can't get DataView to sort correctly.

T

tshad

I do a select into a Dataset, apply a DataView to it and then sort it. But
the sort is not correct. I am sorting it by the UserName and it is not in
alpha order when I bind it to my datagrid.

When the filter and sort look like:
dv.RowFilter: ActionType = 1
dv.Sort = UserFullName asc,SessionID,CreateDate
HistoryLogGrid.DataSource = dv
HistoryLogGrid.DataBind()

I get the following rows:

Joe
Joseph
Robert
Jose
Debbie
Joe
Ana
Ana
Brian
Boz
Charlie
....

Notice how the first few rows are not sorted then they are.

If I reverse the sort so that I have the following for the filter and sort
and databind:
dv.RowFilter: ActionType = 1
dv.Sort = UserFullName desc,SessionID,CreateDate
HistoryLogGrid.DataSource = dv
HistoryLogGrid.DataBind()

I get the following:

....
Charlie
Boz
Brian
Ana
Ana
Joe
Joseph
Robert
Jose
Debbie
Joe

You can see the order has change except for the few that were not sorted in
the first example. And they are in the same order as the first example.

Why is this???

Am I missing something?

Thanks,

Tom
 
S

Scott M.

What happens if you just try this:

dv.Sort = UserFullName
HistoryLogGrid.DataSource = dv
HistoryLogGrid.DataBind()
 
T

tshad

Scott M. said:
What happens if you just try this:

dv.Sort = UserFullName
HistoryLogGrid.DataSource = dv
HistoryLogGrid.DataBind()

Found the problem.

It had to do with a couple of nulls that were in my sort column and my page
adding the names from another column so it looked like there was something
in the column when there wasn't.

Thanks,

Tom
 
C

Cor Ligthert [MVP]

Tshad,

I had the same idea, because you are showing Firstnames and was sorting
FullNames.
:)

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top