Link to home
Start Free TrialLog in
Avatar of sourcelink
sourcelink

asked on

Pivot datatable for GridView and Update

Hello, I have seen several articles on Pivoting data in a datatable to bind to a data grid.  Im using the one referenced in this link:

http://geekswithblogs.net/dotNETvinz/archive/2009/05/10/pivot-data-in-gridview---a-generic-pivot-method-with.aspx

I have the 2 datatables as in the example.

The original normalized version 'dt' with a sqldataadapter.
and the pivoted version 'pivotedTable' as the datasource for the gridview.

I would like to save the data modified in the gridview back to the database in its normalize form.  Possibly using the 'dt' datatable and dataadapter.  

My thoughts are:
use 'getchanges' from pivotedTable:

        Dim changedRecords As System.Data.DataTable
        changedRecords = dt.GetChanges

Then use 'changedrecords' datatable to update the original dt, and da.update to update the database.

My question is: is this a reasonable approach?, is there a better way?.  Does someone have an example.

Im using winforms and vb.net but c++ is ok also.

thanks very much.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sourcelink
sourcelink

ASKER

Thanks for your response.  This seem like it would be a fairly common request, but I havent been able to find anyone that has written someting similar.  I guess that is the path I will be taking. :)