By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,084 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,084 IT Pros & Developers. It's quick & easy.

How to assign the changed datatable in dataview back to a datatable?

P: n/a
Hi all,

After sorting and grouping data using a dataview, then how to transfer
the changed datatable in the dataview to a datatable in C#?

Cheers

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Filtering and sorting do not effect the underlying DataTable and is only part of the current DataView. You have 3 options that I
can see for changing the underlying DataTable (or using the current view):

1. If you need the DataTable for binding, just bind directly to the DataView instead.
2. Iterate the rows of a Copy() of the DataTable and remove those that are not part of your filtered DataView. Sorting will be much
more difficult and should probably be implemented via a DataView on the copied DataTable.
3. Refill a new DataTable by connecting to the DB and using parameters in your query to filter and sort the results, or if your data
is stored in XML, manually filter and sort the data and refill a DataTable.

There is no automated approach for doing this. The DataView is simply a view of a DataTable and in most cases does not effect the
underlying data, with the expection of methods such as DataRowView.Delete().

Just realize that in most data-binding controls a DataView is used in place of a DataTable anyway, so you can just set the
DataSource property of most objects directly to the "view" of the data that you want it to bind to. When you set DataSource to a
DataTable, the DataTable.DefaultView is usually bound in the background anyway.

--
Dave Sexton
dave@www..jwaonline..com
-----------------------------------------------------------------------
"TaeHo Yoo" <yo******@yahoo.com> wrote in message news:uc**************@TK2MSFTNGP15.phx.gbl...
Hi all,

After sorting and grouping data using a dataview, then how to transfer
the changed datatable in the dataview to a datatable in C#?

Cheers

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.