Solved

Pivot datatable for GridView and Update

Posted on 2012-03-27
2
808 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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