Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Cannot bind IList returned from a web service to a repeater

Reply
Thread Tools

Cannot bind IList returned from a web service to a repeater

 
 
Baohua Li
Guest
Posts: n/a
 
      12-10-2003
After I retrieved a list of objects (e.g Employees) and put it into a IList
(ArrayList)
and bind it to a repeater. everything works fine so far.

However, when I get a IList from a web service, it failed. The error is
"Cannot find the property".
But, I can get/set the properties in my programs without problem.

TIA

Li


 
Reply With Quote
 
 
 
 
Lostinet.Web Support
Guest
Posts: n/a
 
      12-10-2003
what Item Type here in your ArrayList ?

--
http://www.lostinet.com/
Lostinet.Web Controls&Components
ComboBox,ComboCalendar DatePicker,SafePwdBox,SmartIFrame,
AlertElement,ConfirmElement,PromptElement,DialogEl ement,ControlHelper
-----------------------

"Baohua Li" <(E-Mail Removed)> дʼ
news:uZ%(E-Mail Removed)...
> After I retrieved a list of objects (e.g Employees) and put it into a

IList
> (ArrayList)
> and bind it to a repeater. everything works fine so far.
>
> However, when I get a IList from a web service, it failed. The error is
> "Cannot find the property".
> But, I can get/set the properties in my programs without problem.
>
> TIA
>
> Li
>
>



 
Reply With Quote
 
 
 
 
Jan Tielens
Guest
Posts: n/a
 
      12-10-2003
The problem is that the members of your real Employee class are implemented
as public properties, but on the generated proxy class, they are implemented
as public fields. You can check this in the Reference.vb or cs file that was
generated when you added a web reference to your client project.

Databound user controls bind to properties, not to fields. For example when
you try to display the collection in an DataGrid, you won't see any columns
either because the DataGrid looks for properties.

A solution is to alter the generated proxy class and change the fields to
properties. But be aware you'd have to do this each time you update your
webservice. A more generic way of solving this issue is to create a wrapper
class that dynamically at run-time wraps your proxy class into a new class
that exposes the fields as properties. I wrote an article about this matter,
you can find it here:
http://www.microsoft.com/belux/nl/ms...ens/webservice
wrapper.mspx
Full source code is available and can be downloaded.
--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan


"Baohua Li" <(E-Mail Removed)> wrote in message
news:uZ#(E-Mail Removed)...
> After I retrieved a list of objects (e.g Employees) and put it into a

IList
> (ArrayList)
> and bind it to a repeater. everything works fine so far.
>
> However, when I get a IList from a web service, it failed. The error is
> "Cannot find the property".
> But, I can get/set the properties in my programs without problem.
>
> TIA
>
> Li
>
>



 
Reply With Quote
 
Baohua Li
Guest
Posts: n/a
 
      12-12-2003
Thank you very much!

"Jan Tielens" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The problem is that the members of your real Employee class are

implemented
> as public properties, but on the generated proxy class, they are

implemented
> as public fields. You can check this in the Reference.vb or cs file that

was
> generated when you added a web reference to your client project.
>
> Databound user controls bind to properties, not to fields. For example

when
> you try to display the collection in an DataGrid, you won't see any

columns
> either because the DataGrid looks for properties.
>
> A solution is to alter the generated proxy class and change the fields to
> properties. But be aware you'd have to do this each time you update your
> webservice. A more generic way of solving this issue is to create a

wrapper
> class that dynamically at run-time wraps your proxy class into a new class
> that exposes the fields as properties. I wrote an article about this

matter,
> you can find it here:
>

http://www.microsoft.com/belux/nl/ms...ens/webservice
> wrapper.mspx
> Full source code is available and can be downloaded.
> --
> Greetz
>
> Jan Tielens
> ________________________________
> Read my weblog: http://weblogs.asp.net/jan
>
>
> "Baohua Li" <(E-Mail Removed)> wrote in message
> news:uZ#(E-Mail Removed)...
> > After I retrieved a list of objects (e.g Employees) and put it into a

> IList
> > (ArrayList)
> > and bind it to a repeater. everything works fine so far.
> >
> > However, when I get a IList from a web service, it failed. The error is
> > "Cannot find the property".
> > But, I can get/set the properties in my programs without problem.
> >
> > TIA
> >
> > Li
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
web reporting with iList support Gene ASP .Net 2 10-17-2007 04:03 PM
Can I convert IList to a DataSet, DataTable or DataView? =?Utf-8?B?Tmljaw==?= ASP .Net 6 07-19-2006 06:39 PM
question about proper way to show an IList of objects? Flip ASP .Net 1 03-28-2005 06:17 PM
Need to pass a method an Ilist DaveF ASP .Net 1 12-08-2004 02:56 PM
Implement IList Interface frank ASP .Net 0 07-11-2003 09:03 AM



Advertisments