Solved

Pivot datatable for GridView and Update

Posted on 2012-03-27
2
793 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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