PC Review


Reply
Thread Tools Rate Thread

Re: Sorting Data in Data Table

 
 
William Ryan eMVP
Guest
Posts: n/a
 
      21st May 2004
You can create a DataView on the DataTable and then call its sort method.

http://www.knowdotnet.com/articles/dataviewsort.html

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
"Parveen" <(E-Mail Removed)> wrote in message
news:9DDF4784-A60D-481E-98D1-(E-Mail Removed)...
> Is this possible?
>
> Parveen



 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGFydmVlbg==?=
Guest
Posts: n/a
 
      22nd May 2004
Thanks! I read your article...it's helpful...one more question
though...I have a grid bound to my datatable and i want to sort
and edit the datatable...i know i can get a sorted version of the
datatable through using a view but what about the changes? My
changes are based on the sort order of the table and I want these
changes to show up in the grid after I've made them. Is it possible
to edit the view and then save these changes back to the datatable

Parveen
 
Reply With Quote
 
William Ryan eMVP
Guest
Posts: n/a
 
      22nd May 2004
Hi Parveen:

Thanks for the kind words. By default, if you bind the grid to the
dataview, than any and all changes you make in the grid will pass through to
the view which pass through to the datatable. So editing the DataView is
editing the datatable and once the grid is bound to it, than any and all
changes will be reflected in the datatable. When you are done, you can just
call update on your adapter passing in the datatable that the view is based
on. The short of it is that you really don't have to do anything different.
Also, you need to end the current edit for a row's state to be changed, but
by clicking a button or menu item, this will happen by default so you really
don't need to do anything else. If you were editing textboxes you'd want to
call EndCurrentEdit of the bindingcontext right before the call to update,
but that shouldn't be necessary based on the scenario you describe here.
Just make sure you don't call .AcceptChanges before update as that will
ensure that the chnages in the view won't ever be sent back to the db...and
Update calls acceptChanges on a row by row basis as it updates anything.

HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

www.devbuzz.com
www.knowdotnet.com
http://www.msmvps.com/williamryan/
"Parveen" <(E-Mail Removed)> wrote in message
news:2070BA56-2A4F-474D-ACB1-(E-Mail Removed)...
> Thanks! I read your article...it's helpful...one more question
> though...I have a grid bound to my datatable and i want to sort
> and edit the datatable...i know i can get a sorted version of the
> datatable through using a view but what about the changes? My
> changes are based on the sort order of the table and I want these
> changes to show up in the grid after I've made them. Is it possible
> to edit the view and then save these changes back to the datatable?
>
> Parveen



 
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
sorting data in pivot table Maria Microsoft Excel Misc 2 19th Jun 2009 10:47 PM
Sorting Data in a Pivot Table =?Utf-8?B?SmFuZXQgQk4=?= Microsoft Excel Misc 5 27th Jun 2006 04:20 AM
Table data sorting Shreekant Patel Microsoft Access Database Table Design 2 21st Mar 2006 10:22 AM
Sorting data in a table =?Utf-8?B?QW1hdGV1cg==?= Microsoft Access 3 25th Jan 2006 04:32 PM
exception during sorting data in a data grid in the constructor of the System.Data.Index class Frank Microsoft Dot NET Framework 0 30th Sep 2003 03:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:43 AM.