By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,130 Members | 2,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,130 IT Pros & 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

P: n/a
Hi

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
clarify.

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
MainForm.CommunicateWithDatabase(args).

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
occurs.

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
changeable.

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.
Bob
bo********@dcml.co.uk
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.