469,938 Members | 2,471 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,938 developers. It's quick & easy.

Problem Hiding Columns when Populating a Datagrid with a DataView of A DataTable From Dataset returned via an Asynchronous Web-Service


I have a webservice that retrieves data from a database, this is then
returned to the calling client application built in windows forms within a
dataset, however upon attempting to create tablestyles to format any of the
columns within the datagrid, the exception "Can-not parent objects created
on one thread to objects created on another" or words to that effect.

I'm not too sure if what I said make sense, but i will add details to

I have an MDI Windows Forms interface, which contains a Method called
CommunicateWithDatabase(args) this then sends the datarequest to the
webservice (tryed both synchronous, asynchronous methods, including creating
the calling method on a different thread and not on a different thread to
the UI thread). Any sub-forms mdiparent'ed to the main form request data via

The data returned from the web-service is held within a DataSet, and all the
data is present in memory using any retrieval/access method.
DataSet.Tables[0] is passed into the subform as a DataTable which is then,
within a control containing a standard DataGrid and DataView is set as the
source of the DataView (Datagrid.Datasource = Dataview; DataView.DataSource
= DataSet.Tables[0])

Once the datasource of the dataview is set, and thus the datagrid. I proceed
to hide columns within the datagrid using the addition of tablestyles with
columnwidth set to 0 or otherwise for non-hidden. This is where the problem

Essentially the problem is currently seen to be that the new tablestyles
can't be created on the datagrid as the underlying dataset was created on
the web-service thread and the new tablestyles has been created on the
windows forms UI thread. I have also tried to pass a dataset into the
webservice and retrieve the same one, but i assumed this wouold not work and
I was seemingly correct about this. As well as having tried a .copy of the
dataset into a locally created new dataset.

It is essential that i use this method of accessing the database via a
web-service for security reasons. However the rest of the interface is still

Does anyone know of any way to allow tablestyles to be created on a datagrid
referencing a dataset/datatable created on a different thread? or a
different workaround for this problem. Please feel free to email me
regarding this issue or any associated topic that may be of use, this is now
becoming a huge problem for this particular development cycle :(

Thanks Very much for any help.
Nov 21 '05 #1
0 2338

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Reb | last post: by
3 posts views Thread by michael haller | last post: by
8 posts views Thread by Inigo Jimenez | last post: by
2 posts views Thread by ddaniel | last post: by
7 posts views Thread by Girish | last post: by
reply views Thread by Tim::.. | last post: by
8 posts views Thread by Dave Hagerich | last post: by
1 post views Thread by tangus via DotNetMonster.com | last post: by
6 posts views Thread by Ron L | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.