Cannot bind IList returned from a web service to a repeater

Discussion in 'ASP .Net Web Services' started by Baohua Li, Dec 10, 2003.

  1. Baohua Li

    Baohua Li Guest

    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
     
    Baohua Li, Dec 10, 2003
    #1
    1. Advertising

  2. what Item Type here in your ArrayList ?

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

    "Baohua Li" <> дÈëÓʼþ
    news:uZ%...
    > 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
    >
    >
     
    Lostinet.Web Support, Dec 10, 2003
    #2
    1. Advertising

  3. Baohua Li

    Jan Tielens Guest

    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/msdn/community/columns/jtielens/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" <> wrote in message
    news:uZ#...
    > 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
    >
    >
     
    Jan Tielens, Dec 10, 2003
    #3
  4. Baohua Li

    Baohua Li Guest

    Thank you very much!

    "Jan Tielens" <> wrote in message
    news:...
    > 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/msdn/community/columns/jtielens/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" <> wrote in message
    > news:uZ#...
    > > 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
    > >
    > >

    >
    >
     
    Baohua Li, Dec 12, 2003
    #4
    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. frank

    Implement IList Interface

    frank, Jul 11, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    584
    frank
    Jul 11, 2003
  2. DaveF

    Need to pass a method an Ilist

    DaveF, Dec 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    330
    Karl Seguin
    Dec 8, 2004
  3. Flip
    Replies:
    1
    Views:
    485
    Brock Allen
    Mar 28, 2005
  4. =?Utf-8?B?Tmljaw==?=
    Replies:
    6
    Views:
    25,084
    =?Utf-8?B?Tmljaw==?=
    Jul 19, 2006
  5. Gene
    Replies:
    2
    Views:
    305
Loading...

Share This Page