Somebody MUST know the answer to this...

Somebody MUST know the answer to this...

Post by William Bu » Wed, 31 May 2006 17:40:35


Hi folks

Excuse the title, but i've been looking for an answer to this simple problem
for months now and nobody seems to be able to help. I am using VS 2005.

I have a web service which returns a data table through a web method.

I also have a win form with a combo box. The combo box is linked to a
binding source, and the binding source is linked to the web service (all
done through the IDE; i.e. no code written by me). However, when I open the
form there is no data in the combo box.

I would expect that if the IDE allows me to set these properties that it
should work without the need to write code. I can get it working by hand
coding it, but that makes the whole point of setting these properties at
design time pointless.

I get the same effect when I drag a grid view from the data source window -
the grid doesn't fill with data.

What am I missing?

Thanks

Will
 
 
 

Somebody MUST know the answer to this...

Post by 10 » Wed, 31 May 2006 22:37:37

William,

First I want to make clear that I don't have experience with binding to a
webservice, here is something that might help you.

When you create a data source (binding source to a database) the IDE for
WinForms adds Form.Load event handler and code in it to get the data from
the db.

Some times (depending on how one creates the binding source) this code is
not generated. Because of this at design time everything looks fine, but
when it comes the run-time the binding source is empty. I think you may have
similar problem.

Just keep in mind that the binding source doesn't take care of connecting to
the web service or whatever. There must be some code that does that.


--
HTH
Stoitcho Goutsev (100)

 
 
 

Somebody MUST know the answer to this...

Post by William Bu » Thu, 01 Jun 2006 17:09:22

Thanks for taking the time to reply.

This is interesting.... I had assumed that the IDE would do that for me. It
seems a bit misleading that it lets you set all these things up in the IDE,
but then doesn't actually do it properly (i'm from a Delphi background so I
am used to the IDE actually working properly and without bugs!).

I think you are right about it not connecting to the web service - I have
managed to get the data from the web service, but I basically had to undo
everything that was set by the IDE and hand code it.

Thanks again.

Will
 
 
 

Somebody MUST know the answer to this...

Post by William Bu » Mon, 05 Jun 2006 08:21:06

I have worked it out..... thought someone might be interested in future.

You have to retrieve a new instance of your datatable from the web service
(e.g. myDataTable = myWebSvc.GetMyData()), then point your
bindingsource.datasource to this! It's quite simple but shows that you still
need to do some code to get it to work!