PC Review


Reply
Thread Tools Rate Thread

Dataview not in order after Sort

 
 
Pewak
Guest
Posts: n/a
 
      9th Mar 2004
Hi,

I am adding a row to the datatable, and then I want to sort it, so I
put this into a dataview, and use the following code to sort it, but
it stays in the same order after I've done it.

datatable.rows.add(newrow)

dim dv as dataview

dv = datatable.DefaultView
dv.Sort = ("process_desc")

where process_desc is the name of the column to order, but it stays in
the same order. Any ideas why this is???
 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      9th Mar 2004
Hi Pewak,

DataView does not sort DataTable, it only represents the data in sorted
order.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Pewak" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I am adding a row to the datatable, and then I want to sort it, so I
> put this into a dataview, and use the following code to sort it, but
> it stays in the same order after I've done it.
>
> datatable.rows.add(newrow)
>
> dim dv as dataview
>
> dv = datatable.DefaultView
> dv.Sort = ("process_desc")
>
> where process_desc is the name of the column to order, but it stays in
> the same order. Any ideas why this is???



 
Reply With Quote
 
Pete Walker
Guest
Posts: n/a
 
      9th Mar 2004
hi Miha ,

I have looked at the dataview after the sort on the column and it
appears in the same order. I intend to append this dataview into a new
dataset after the sort. Have you any suggestions how to do this ?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Cor
Guest
Posts: n/a
 
      9th Mar 2004
Hi Pete,

I see no function for it, but what you can do is clone a dataset and than
while itterating thru your dataview add new rows for that new dataset and
than copy the items using the dataview to that new dataset also itterating
thru that.

It is not a real big job to do, I think about 10 rows of code in vb and 20
in C# (including {})

Cor


 
Reply With Quote
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      10th Mar 2004
Hi Pete,

One solution was provided by Cor.
However, why would you want to copy sorted rows?

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"Pete Walker" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hi Miha ,
>
> I have looked at the dataview after the sort on the column and it
> appears in the same order. I intend to append this dataview into a new
> dataset after the sort. Have you any suggestions how to do this ?
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
Pete Walker
Guest
Posts: n/a
 
      10th Mar 2004


Sorry, I didn't explain myself clearly, I have 3 seperate datasets that
have to be bound into one datagrid, because as far as I know you can't
bind multiple datasets to one datagrid, so I thought the best way was to
merge these 3 datasets into one like follows and then bind the merged
dataset into the datagrid. (hope this makes sense !!!)

1st Dataset
Overall Figure xxx yyy zzz

2nd Dataset (the bit I want in order)
A xxx yyy zzz
B xxx yyy zzz
C xxx yyy zzz
D xxx yyy zzz

3rd Dataset
Total Figure

This is where I wanted the 2nd dataset sorted


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
noeldp
Guest
Posts: n/a
 
      16th Mar 2004
good news - you can get at the sorted dataview if you use the correct
syntax (credit goes to somebody else, i can't find the link right
now)

this syntax works, it returns the rows in sorted order:

dataview.sort "some column name"
for i = 0 to dataview.count - 1
dataview(i).item()

this syntax fails to return it in sorted order:

dataview.sort "some column name"
for i = 0 to dataview.table.rows.count - 1
dataview.table.row(i).item()

if you think this is silly, why not provide a dataset.sort method in
the first place, right?


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataView sort =?Utf-8?B?RGFz?= Microsoft C# .NET 1 29th Jun 2005 08:54 PM
Order By or Dataview sort quickest? Earl Microsoft Dot NET Compact Framework 2 15th Nov 2004 01:55 PM
Dataview will not sort Raymond Lewallen Microsoft VB .NET 9 8th Nov 2004 08:18 PM
Dataview will not sort Raymond Lewallen Microsoft Dot NET 9 8th Nov 2004 08:18 PM
DataView sort fails to sort on fields with comma in field names Mone Hsieh Microsoft ADO .NET 1 14th May 2004 09:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:23 PM.