PC Review


Reply
Thread Tools Rate Thread

DataView/DataGrid Sort

 
 
Gene Hubert
Guest
Posts: n/a
 
      18th Aug 2004
I'm using the DefaultView from the Datasource for a DataGrid to
present the data in a particular order. It seems that sorting in this
way is an "Active Sort", as is the default sort that is provided by
clicking on a column header. By "Active Sort", I mean that editing a
value in a sorted column may cause the record to be moved to maintain
the sort order.

Is there an efficient way to present the data in a given order but not
have it be an "Active Sort." That is, I don't want records jumping
around to different places because the value in a sorted column has
been edited. I also need to allow a user to select which column the
grid is sorted on by clicking on the column header.

Thanks Much,
Gene H.
 
Reply With Quote
 
 
 
 
Andy Becker
Guest
Posts: n/a
 
      18th Aug 2004
"Gene Hubert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is there an efficient way to present the data in a given order but not
> have it be an "Active Sort." That is, I don't want records jumping
> around to different places because the value in a sorted column has
> been edited. I also need to allow a user to select which column the
> grid is sorted on by clicking on the column header.
>
> Thanks Much,
> Gene H.


Only to feed it a data source which is pre-sorted as desired. The jumping
can't be prevented once a column header has been clicked, though, and some
data in that column edited.

The DataGrid should allow you to click on column headings and sort... The
property is AllowSorting, but I can't recall the default value at the
moment.

Does this help any?

Best Regards,

Andy


 
Reply With Quote
 
Gene Hubert
Guest
Posts: n/a
 
      19th Aug 2004
Thanks Andy. That 'bout what I figured.

Is there a way to bulk move records from one datatable to another?
Here's what I'm doing now, a record at a time...

Dim dt, dtSort As DataTable
Dim dv As DataView
Dim dr As DataRow

....do a bunch of stuff to load dt...

dv = dt.DefaultView 'set initial display order
dv.Sort = "Sort ASC, Name ASC"

dtSort = dt.Clone 'copy datatable structure
dtSort.DefaultView.Sort = Nothing 'remove the sort

For Each dr In dt.Select 'move the data
dtSort.ImportRow(dr)
Next

FileList.DataSource = dtSort

"Andy Becker" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> "Gene Hubert" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Is there an efficient way to present the data in a given order but not
> > have it be an "Active Sort." That is, I don't want records jumping
> > around to different places because the value in a sorted column has
> > been edited. I also need to allow a user to select which column the
> > grid is sorted on by clicking on the column header.
> >
> > Thanks Much,
> > Gene H.

>
> Only to feed it a data source which is pre-sorted as desired. The jumping
> can't be prevented once a column header has been clicked, though, and some
> data in that column edited.
>
> The DataGrid should allow you to click on column headings and sort... The
> property is AllowSorting, but I can't recall the default value at the
> moment.
>
> Does this help any?
>
> Best Regards,
>
> Andy

 
Reply With Quote
 
Andy Becker
Guest
Posts: n/a
 
      19th Aug 2004
"Gene Hubert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Andy. That 'bout what I figured.
>
> Is there a way to bulk move records from one datatable to another?


I haven't ever used it (yet), but it looks like you can just use
DataTable.Copy. In your particular case, it may be approriate to sort the
copy instead of the other way around, to leave an unsorted DefaultView
behind... But I don't know much about the application. :-)

Best Regards,

Andy


 
Reply With Quote
 
Gene Hubert
Guest
Posts: n/a
 
      20th Aug 2004
I couldn't get it to work using datatable.copy. It seems that if the
datatable has data in it, and then you change the sort property, the
data is immediately reshuffled.

If you copy the data using datatable.copy, the sort property of the
target datatable is set to empty string, but the data in it does not
present in the sort order of the source datatable used in the copy.

Gene H.

"Andy Becker" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> "Gene Hubert" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Thanks Andy. That 'bout what I figured.
> >
> > Is there a way to bulk move records from one datatable to another?

>
> I haven't ever used it (yet), but it looks like you can just use
> DataTable.Copy. In your particular case, it may be approriate to sort the
> copy instead of the other way around, to leave an unsorted DefaultView
> behind... But I don't know much about the application. :-)
>
> Best Regards,
>
> Andy

 
Reply With Quote
 
Andy Becker
Guest
Posts: n/a
 
      20th Aug 2004
"Gene Hubert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I couldn't get it to work using datatable.copy. It seems that if the
> datatable has data in it, and then you change the sort property, the
> data is immediately reshuffled.
>
> If you copy the data using datatable.copy, the sort property of the
> target datatable is set to empty string, but the data in it does not
> present in the sort order of the source datatable used in the copy.
>
> Gene H.


I don't think I was very clear in expressing my thoughts. If it is still of
use to you, the idea was to pull rows into a datatable with the required
sort already present, i.e. an "order by" clause. Then copy this to another
datatable and sort as needed.

Are you trying to make a copy of the row in their natural (unsorted) order?

Best Regards,

Andy


 
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
Datagrid / Dataview won't sort troyblakely@gmail.com Microsoft ASP .NET 1 5th Nov 2005 01:29 PM
Datagrid / Dataview Help On Select after SORT... =?Utf-8?B?QnJ1Y2UgUHVsbHVt?= Microsoft Dot NET 4 25th Oct 2005 11:09 PM
Sort Datagrid without Dataview msxkim@yahoo.com Microsoft Dot NET Framework Forms 1 5th Oct 2005 04:10 PM
DataView sort does not show in DataGrid Bill Todd Microsoft C# .NET 4 5th May 2004 04:02 AM
Obtaining the current row index in dataGrid with sort by dataview John Shaw Microsoft ADO .NET 3 22nd Sep 2003 05:41 PM


Features
 

Advertising
 

Newsgroups
 


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