Re: Gridview Linq Query
Peter Ritchie <[email protected]> Thu, 11 Sep 2008 12:47:17 -0400
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
It's because GridViewRowCollection implements
System.Collections.IEnumerable (for whatever reason). This is essentially
the same as System.Collections.IEnumerable<Object>--which is why
everything is an Object. VB.NET is happy to accept that at compile time,
leaving it to deal with it a runtime.
You need to tell the compiler the information it can't infer, for example:
Dim gridList As IEnumerable(Of GridViewRow) =3D customerGrid.Rows
Dim customerList =3D From cust In gridList _
Select cust.Cells(4).Text _
Distinct
Cheers -- Peter
On Thu, 11 Sep 2008 10:46:09 -0500, Booth, Bill
<[email protected]> wrote:
>Hi All,
>I am trying to run a Linq query on a GridView Rows Collection that will
>select the distinct contents of one cell. The query below will do the
>job; however, it uses late binding. The variables cust and customerList
>are both object types. I just cannot seem to get around this.
>Any advice will be appreciated.
>Bill
>
>Dim gridList As GridViewRowCollection =3D CustomerGrid.Rows
>
>
>Dim customerList =3D From cust In gridList _
> Select cust.Cells(4).Text _
> Distinct
>
>For Each i In customerList
> Debug.WriteLine(i)
>Next
>
>The information in this e-mail is confidential, may be legally privileged
and is intended solely for the addressee. If you have received this e-mail
in error, you are hereby notified that any use, distribution, or copying
of this communication is strictly prohibited.
>
>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>This list is hosted by DevelopMentor=AE http://www.develop.com
>
>View archives and manage your subscription(s) at
http://discuss.develop.com
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
This list is hosted by DevelopMentor=AE http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com