Can't Bind Datagrid with Dataset returned by WebService

Q

QuocSI

Hi all,

I've wrote a Webservice which return a Dataset.

I have made an object on a client pc to acces this webservice.
The asynchhroned call to webservice fill correctly my dataset.

But when in my form, I wish to use this Dataset, I get error at runtime.

Datagrid1.datasource = MyObject.MyDataset

Do not provide error on compilation.


With an asynchroned call, does the system create a secondary thread.
The dataset seem not to be part of the principal thread.
So how can I bind then returned datas.

Thanks a lot for your help.
 
T

Trebek

It is possible that the callback is not on the Message pump thread. I would
suggest that you check and see by calling InvokeRequired. If so, simply
define a delegate and method that implements this delegate to bind the
datagrid and invoke it from the web service async callback.

EX in C# (Sorry -- never messed with VB):

//Delegate definition
public delegate void DelBindMyGrid(DataSet ds);

//In async callback
DataSet ds = ws.EndMethod(ir);
this.Invoke(new DelBindMyGrid(BindGrid),new object[]{ds});


//Delegate method to bind grid -- called thru invoke to run under msg
pump thread
private void BindGrid(DataSet ds)
{
Datagrid1.datasource = MyObject.MyDataset;
}

HTH,

Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top