Solved

Pivot datatable for GridView and Update

Posted on 2012-03-27
2
781 Views
Last Modified: 2012-03-31
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.
0
Comment
Question by:sourcelink
2 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 37774104
I think that is a reason able approach. Given that data in PivotedTable can not be saved back to the DB using adapter then you have two options

1) Getchanges and apply to dt then save dt using adapter
2) Getchanges, loop and save changes to db manually.
0
 

Author Comment

by:sourcelink
ID: 37791577
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. :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now