Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Binding a collection of collections

Binding a collection of collections

Scheduled Pinned Locked Moved ASP.NET
htmlwpfwcfhelp
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    shambho
    wrote on last edited by
    #1

    Consider a Collections of Organisations and let that collectionObject be called collectionOrg. Each organisation Object in the collection have name, address and an object called countryObject which has country Id and country Name. I want to bind this collectionOrg to a datagrid. Code for this is OrgDataGrid.DataSource = collectionOrg; OrgDataGrid.DataBind(); and in the html part to bind this property to the But as this CountryObj.Name gives an error. What should I do to handle this error. Thanks in advance With Thanks and Regards Anand Ignorance is Bliss

    M 1 Reply Last reply
    0
    • S shambho

      Consider a Collections of Organisations and let that collectionObject be called collectionOrg. Each organisation Object in the collection have name, address and an object called countryObject which has country Id and country Name. I want to bind this collectionOrg to a datagrid. Code for this is OrgDataGrid.DataSource = collectionOrg; OrgDataGrid.DataBind(); and in the html part to bind this property to the But as this CountryObj.Name gives an error. What should I do to handle this error. Thanks in advance With Thanks and Regards Anand Ignorance is Bliss

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, Why don't you provide a little more information about the error and sample code instead of letting people diagnose the problem of your sample code just from fews words "gives an error ..."?

      S 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, Why don't you provide a little more information about the error and sample code instead of letting people diagnose the problem of your sample code just from fews words "gives an error ..."?

        S Offline
        S Offline
        shambho
        wrote on last edited by
        #3

        It gives an error unable to find property "Name" if i provide "Name" as datatextfield which is correct as the collection directly donot have Name only Collection.Country.Name is available. Even "Country.Name" gives the same error cannot find property. the bound column to datagrid is like as follows when i set datafield as name or country.name it gives error cannot find property anyway Thanks for the reply Not everything that can be counted counts, and not everything that counts can be counted -- modified at 11:45 Wednesday 28th September, 2005

        M 1 Reply Last reply
        0
        • S shambho

          It gives an error unable to find property "Name" if i provide "Name" as datatextfield which is correct as the collection directly donot have Name only Collection.Country.Name is available. Even "Country.Name" gives the same error cannot find property. the bound column to datagrid is like as follows when i set datafield as name or country.name it gives error cannot find property anyway Thanks for the reply Not everything that can be counted counts, and not everything that counts can be counted -- modified at 11:45 Wednesday 28th September, 2005

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          Because, you bind a property (Name) of a member (Country) of an item (Organization) in the collection, you should not use the bound column as the DataTextField requires you to specify a member of the Organization object. In this case, you can use a template column, and provide a data binding expression using the DataBinder class.

          S 1 Reply Last reply
          0
          • M minhpc_bk

            Because, you bind a property (Name) of a member (Country) of an item (Organization) in the collection, you should not use the bound column as the DataTextField requires you to specify a member of the Organization object. In this case, you can use a template column, and provide a data binding expression using the DataBinder class.

            S Offline
            S Offline
            shambho
            wrote on last edited by
            #5

            Great minhpc(sorry if its not ur good name). It works. Thanks and Cheers Anand Not everything that can be counted counts, and not everything that counts can be counted

            M 1 Reply Last reply
            0
            • S shambho

              Great minhpc(sorry if its not ur good name). It works. Thanks and Cheers Anand Not everything that can be counted counts, and not everything that counts can be counted

              M Offline
              M Offline
              minhpc_bk
              wrote on last edited by
              #6

              shambho wrote: It works. Glad to hear that ;P shambho wrote: minhpc(sorry if its not ur good name). That's my name, but in short :)

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups