PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Re: Sorting Data in Data Table
Forums
Newsgroups
Microsoft DotNet
Microsoft ADO .NET
Re: Sorting Data in Data Table
![]() |
Re: Sorting Data in Data Table |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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" <anonymous@discussions.microsoft.com> wrote in message news:9DDF4784-A60D-481E-98D1-93FD13DD4D1A@microsoft.com... > Is this possible? > > Parveen |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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" <anonymous@discussions.microsoft.com> wrote in message news:2070BA56-2A4F-474D-ACB1-913377C86AA0@microsoft.com... > 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 |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

