Can't Bind Datagrid with Dataset returned by WebService

Discussion in 'ASP .Net Web Services' started by QuocSI, Aug 12, 2004.

  1. QuocSI

    QuocSI Guest

    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.
     
    QuocSI, Aug 12, 2004
    #1
    1. Advertising

  2. QuocSI

    Trebek Guest

    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

    "QuocSI" <> wrote in message
    news:...
    > 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.
    >
    >
     
    Trebek, Aug 12, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Programatix
    Replies:
    1
    Views:
    383
    Kathleen Dollard
    Jul 17, 2003
  2. AFN
    Replies:
    3
    Views:
    3,232
    Kevin Spencer
    Feb 16, 2004
  3. Randy Hayes
    Replies:
    0
    Views:
    125
    Randy Hayes
    Dec 21, 2003
  4. Randy Hayes
    Replies:
    1
    Views:
    152
  5. Randy Hayes
    Replies:
    1
    Views:
    219
Loading...

Share This Page