none
Data in object RRS feed

  • Question

  • I am using a WCF service to get some data back. Once I get the data its found in an object. I would prefer to show this data in a table/gridview etc but I can't bind the object unless its an IList/Enumerable etc.

    How could I overcome this?

    Wednesday, January 16, 2013 8:25 AM

Answers

  • Hi,

    As far as I know, GridView control can be bound to a data source control (such as SqlDataSource, ObjectDataSource), and any data source that implements the System.Collections.IEnumerable interface(such as System.Data.DataView, System.Collections.ArrayList, or System.Collections.Hashtable).

    But you may try retrieve the data and put them in a ArrayList instance or one implements the IEnumerable interface.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 17, 2013 6:55 AM
    Moderator
  • Hi,
    it is by design that GridView and other related controls will fetch and display data from DataSource controls or Collection objects.Just imagine how your GridView will display lots of rows of data dynamically once you set the DataSource ?
    GridView is supposed to iterate over a list of data through some methods like MoveNext and Currect property. Now to ensure that these methods should be present in the DataSource your DataSource should be a Collection.And Collection means it has implemented IEnumerable interface(this interface contains Current Property,MoveNext() method etc. )
    Hope this helps.

    One good question is equivalent to ten best answers.

    Thursday, January 17, 2013 7:36 AM

All replies

  • Hi,

    As far as I know, GridView control can be bound to a data source control (such as SqlDataSource, ObjectDataSource), and any data source that implements the System.Collections.IEnumerable interface(such as System.Data.DataView, System.Collections.ArrayList, or System.Collections.Hashtable).

    But you may try retrieve the data and put them in a ArrayList instance or one implements the IEnumerable interface.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, January 17, 2013 6:55 AM
    Moderator
  • Hi,
    it is by design that GridView and other related controls will fetch and display data from DataSource controls or Collection objects.Just imagine how your GridView will display lots of rows of data dynamically once you set the DataSource ?
    GridView is supposed to iterate over a list of data through some methods like MoveNext and Currect property. Now to ensure that these methods should be present in the DataSource your DataSource should be a Collection.And Collection means it has implemented IEnumerable interface(this interface contains Current Property,MoveNext() method etc. )
    Hope this helps.

    One good question is equivalent to ten best answers.

    Thursday, January 17, 2013 7:36 AM