Can't bind IEnumerable to DataGridView

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ronald S. Cook

    Can't bind IEnumerable to DataGridView

    Does anyone know why an IEnumerable might not bind to a DataGridView?

    Thanks,
    Ron
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Can't bind IEnumerable to DataGridView

    Ron,

    Is this in System.Windows. Forms or in ASP.NET? If the answer is the
    former, then the requirement is that the collection implement IList, not
    IEnumerable. With ASP.NET, I think you ^should^ be able to bind an
    IEnumerable to a data source, but you would have to check up on that.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Ronald S. Cook" <rcook@westinis .comwrote in message
    news:23CF632B-2420-424F-B8B1-D0319513DAE3@mi crosoft.com...
    Does anyone know why an IEnumerable might not bind to a DataGridView?
    >
    Thanks,
    Ron

    Comment

    • Ronald S. Cook

      #3
      Re: Can't bind IEnumerable to DataGridView

      Yes, is't a Win Forms app and I can bind other IEnumerables. Just not sure
      why not this one. Here it is in case you notice anything:

      Public Function GetProgramPrice ListByMedicineI d(ByVal MedicineId) As
      IEnumerable

      Dim y As IEnumerable(Of ProgramMedicine Price)

      y = From pmp In dc.ProgramMedic inePrices _
      Where pmp.MedicineId = MedicineId

      Dim x As IEnumerable
      x = From xy In y _
      Where xy.ProgramMedic inePriceDate = (From test In y _
      Where test.ProgramId =
      xy.ProgramId _
      Select
      test.ProgramMed icinePriceDate) .Max _
      Select xy.Program.Prog ramName, _
      xy.ProgramMedic inePriceDate, _
      xy.ProgramMedic inePriceDollars

      Return x



      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c omwrote in
      message news:O9VbWo%23c IHA.5668@TK2MSF TNGP05.phx.gbl. ..
      Ron,
      >
      Is this in System.Windows. Forms or in ASP.NET? If the answer is the
      former, then the requirement is that the collection implement IList, not
      IEnumerable. With ASP.NET, I think you ^should^ be able to bind an
      IEnumerable to a data source, but you would have to check up on that.
      >
      >
      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m
      >
      "Ronald S. Cook" <rcook@westinis .comwrote in message
      news:23CF632B-2420-424F-B8B1-D0319513DAE3@mi crosoft.com...
      >Does anyone know why an IEnumerable might not bind to a DataGridView?
      >>
      >Thanks,
      >Ron
      >
      >

      Comment

      Working...