473,385 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
1 5837
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Brian Bischof | last post by:
I'm using a third-party tool that takes a DataTable as a parameter. I really need to pass it a DataView instead. When I try to explicitly cast the DataView as a DataTable I get an error that they...
5
by: Richard | last post by:
Windows Forms, csharp, 20 rows in DataTable 14 shown in view after filter applied. For any of the 14 how do I do the datarow or something else thing to access the data in the row of the table...
4
by: Kris Rudin | last post by:
I am displaying a table of information on a web page, using an asp:table that I populate dynamically. On this page I give the user the options to group the rows by certain fields, and/or filter the...
2
by: Fredrik Rodin | last post by:
All, I've been looking around for a solution to my problem for a couple of days now. In short, here's my situation: 1. I'm getting a result from a component back as a datatable and I have...
4
by: Bruce A. Julseth | last post by:
I'm new to VB.NET and just gettng into database "Learning." How do I decide if I need a DataTable or a DataView. Thanks... Bruce
3
by: Rich | last post by:
Hello, I am populating a datagridview from a datatable and filtering the number of rows with a dataview object. Is there a way to retrieve the rows displayed by the datagridview into a separate...
11
by: Santosh | last post by:
Dear all , i am writting following code. if(Page.IsPostBack==false) { try { BindSectionDropDownlist();
2
by: am72de | last post by:
Hi all, I have a problem with the DataTable.Reset(). After resetting the DataTable the count of the DataView is no longer equal with the DataTable.Rows.Count, so the second Assert fails. ...
1
by: Ronald S. Cook | last post by:
If I add a row to a DataView, will the row automatically be added to the underlying DataTable? If so, I'm trying to understand why anyone would add a row to a DataView when they may as well just...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.