Dean Slindee
4/8/2008 7:00:00 PM
Here is the Cast statement I would like to use:
Dim dt As DataTable
dt = CType(query.Cast(Of tblAdminAddressType)(),
System.Data.DataTable)
Perhaps my approach is in error, as today it produces this result:
Exception Type: System.InvalidCastException
Exception Message: Unable to cast object of type
'System.Data.Linq.DataQuery`1[Admin.tblAdminAddressType]' to type
'System.Data.DataTable'.
"Cor Ligthert[MVP]" <notmyfirstname@planet.nl> wrote in message
news:9E778EF3-502A-44B8-85D5-543239919447@microsoft.com...
> Dean,
>
> The listview is in noway an AdoNet control, while Linq is only AdoNet as
> it is for Linq to AdoNet
>
> Why not use bindable controls as meant for those. The listview is an old
> verhicle basicly for things as windows explorer and more like that. The
> bindable controls where probably not created as it was possible with
> something that is from far in the past millenium.
>
> However if you want to use a control as old as almost a T Ford, than make
> it workable, but that has no purpose for others, who just use DataBindable
> controls as they want to DataBind.
>
> Cor
>
> "Dean Slindee" <slindee@charter.net> schreef in bericht
> news:DE390062-BED1-42EC-9B5D-88E4546A1BB1@microsoft.com...
>> Currently using a legacy Winform listview, that is filled by a function
>> from datatable(0) in a dataset. This works fine as the datatable has
>> column headers and data rows that correspond to listview headers and
>> listview rows.
>>
>> Would like to use Linq to SQL to populate the same legacy WinForm
>> listview. The code below retrieves the IOrderedQuery object correctly:
>> Dim dc As New dcAdminDataContext
>> Dim query = From tblAdminAddressType In
>> dc.tblAdminAddressTypes _
>> Order By tblAdminAddressType.AddressTypeID
>> gvwAdminData.DataSource = query
>>
>> The last statement fills a datagridview thru the .DataSource property.
>> Since, a listview has no .DataSource property, I am at an impasse as to
>> how to convert query to a datatable, or ? I do not want to specify the
>> data column names within each query nor declare a class for the query
>> structure. Any ideas?
>>
>> Thanks in advance,
>> Dean S
>