Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default ListObject does not update DataSource when cell value changes

This causes the DataSource (a DataSet) to not being in sync with the values
displayed by the ListObject.

The underlying DataSource is updated only when a new ListObject row is added
from the Worksheet. But if cell values of this last added row is updated by
user, the changes are not reflected into the underlying DataSet.

The documentation (http://msdn2.microsoft.com/en-us/library/bybtbt99.aspx)
reports "You do not need to save ListObject changes to the in-memory data
source. When you bind a ListObject control to data, the ListObject control
automatically saves changes to the in-memory data source without requiring
additional code." But it's not the case here.

Steps to Reproduce

* Under Visual Studio 2008, creates a new Excel 2007 Workbook project
(VB.Net).
* Create a new DataSet item to the project.
* Using the DataSet designer, add a DataTable to the DataSet. Name it
DataTable1 and add two String-typed DataColumn DataColumn1 and DataColumn2.
* Save DataSet and select Data Show Data Sources menu.
* From the Data Sources panel, drag the DataTable1 onto Sheet1 of the Excel
Workbook. This automatically adds the DataTable1ListObject and
DataTable1BindingSource controls as well as an instance of DataSet1.
* Also add a Button onto onto Sheet1 of the Excel Workbook, and add handler
to the Click event.
* In the Button1.Click event handler add a breakpoint or code to inspect
content of the DataSet1.DataTable1.Rows and
DataSet1.DataTable1.GetChanges.Rows collections at run-time.
* Make the same for the DataTable1ListObject.Change event.
* Start Debugging the Project (F5). This shows up the Excel workbook with an
empty instance of the ListObject representing the 2 columns of the underlying
DataTable1.
* Add some values into cells of the first row of the ListOject (like "ABC",
"DEF"), and then select another cell away from the ListObject. This raises
the DataTable1ListObject.Change event. If you inspect content of the
underlying DataTable1, you can see this change has been reflected.
* Now change cell values of the ListObject row you just added with "123",
"456", and then select another cell away from the ListObject. The
DataTable1ListObject.Change event is NOT raised. Inspect content of the
underlying DataTable1, you can see this last changes have NOT been reflected
at all. DataTable1.GetChanges still returns values of the row when it has
been first added ("ABC", "DEF instead of "123", "456").

Actual Results

Changing value of cells bound to ListObject does not raise the
ListObject.Change event nor update the underlying DataSource accordingly.
This behavior can also be observed when:
* Loading existing data into the ListObject, changing some values / adding
some new rows, and then attempting to get changes from the underlying DataSet
using DataSet1.DataTable1.GetChanges().
* Using a BindingSource component or not.

Expected Results

As soon as user changes a cell value and validates by changing current
selection or typing ENTER, the ListObject.Change event should be raised and
underlying DataSource (DataSet) being updated accordingly.

Are we supposed to call any method to ensure the ListObject well
detects/propagates changes to the underlying DataTable?

Many thanks in advance for your help.

Best Regards,

Sébastien

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot get ListObject using C++ haiying Excel Programming 3 April 28th 07 07:06 AM
ListObject - XML question Raghu Excel Programming 0 February 16th 07 11:54 PM
Update a ListObject from a another Excel sheet Thomas V Excel Programming 0 October 5th 06 03:48 PM
Creating ListObject using an XmlMap datasource. Chris Capon Excel Programming 0 October 4th 06 12:03 AM
listobject issue kevinc Excel Programming 1 April 26th 06 02:28 PM


All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"