Load collection in datagrid

Posts   
 
    
jeffreydb
User
Posts: 5
Joined: 16-Mar-2006
# Posted on: 16-Mar-2006 11:43:16   

Hi there,

I'm just new to .NET and LLBLGen and i got a simple question. This is the situation.

I have made a webservice with a database using LLBLGen. There's a webmethod like:


[WebMethod]
    public UserCollection getContacts() 
    {
        UserCollection users = new UserCollection();
        users.GetMulti(null);
        return users;
    }

At the client side i want to load the data, that i get from the webservice, into a datagrid. I tried a few things that i saw in a couple of tutorials, but nothing works.

This is what i've tried:


private void buttonGet_Click(object sender, EventArgs e)
{
     DEweb.Service service = new Data_Exchange.DEweb.Service();
            service.Url = "http://localhost:1490/DEweb/Service.asmx";
            service.getContactsCompleted += new 
Data_Exchange.DEweb.getContactsCompletedEventHandler(service_getContactsCompleted);
}

void service_getContactsCompleted(object sender, Data_Exchange.DEweb.getContactsCompletedEventArgs e)
        {
            dataGridContacts.DataSource = e.Result;
        }

I there anyone who can help me with this problem?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 16-Mar-2006 14:47:35   

First you should be aware of the issues concerning the web service: Please refer to the LLBLgen Pro documentation "Using the generated code -> XML Webservices support -> Caveats using wsdl.exe/VS.NET 2002/3 and the entity classes"

If you will be using the datagrid for Read-Only purposes, I recommend you use a TypedList

And ayway I think the following line of code:

dataGridContacts.DataSource = e.Result needs a cast for the "e.Result" to any IEnumerable object whether it's DataTable or EntityCollection.

jeffreydb
User
Posts: 5
Joined: 16-Mar-2006
# Posted on: 16-Mar-2006 16:10:45   

Thanks for your reply. I already tried the code from de documentation like this:


            DEweb.Service service = new Data_Exchange.DEweb.Service();
            UserCollection users = (UserCollection)service.getContacts();
            dataGridContacts.DataSource = users;

But i'm working with selfservicing instead of adapter. And this piece of code won't work.

jeffreydb
User
Posts: 5
Joined: 16-Mar-2006
# Posted on: 16-Mar-2006 17:28:25   

I found the problem. I had to change the Reference.cs.

Thanks for your reaction.