PC Review Forums Newsgroups Microsoft DotNet Microsoft ADO .NET Re: Sorting Data in Data Table

Reply

Re: Sorting Data in Data Table

 
Thread Tools Rate Thread
Old 21-05-2004, 09:27 PM   #1
William Ryan eMVP
Guest
 
Posts: n/a
Default Re: Sorting Data in Data Table


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



  Reply With Quote
Old 22-05-2004, 12:16 AM   #2
=?Utf-8?B?UGFydmVlbg==?=
Guest
 
Posts: n/a
Default Re: Sorting Data in Data Table

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
Old 22-05-2004, 02:43 AM   #3
William Ryan eMVP
Guest
 
Posts: n/a
Default Re: Sorting Data in Data Table

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



  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off