S
sjoshi
I have a simple Grid template that I'm trying to use with this LINQ
SQL:
from publisher in SampleData.Publishers
join book in SampleData.Books
on publisher equals book.Publisher into PublisherBooks
from book in PublisherBooks.DefaultIfEmpty(new Book { Title = "(no
books)" })
select new
{
Publisher = publisher.Name,
Books = book
};
The grid is defined as :
<asp:GridView ID="GridViewGroupJoin" AutoGenerateColumns="false"
runat="server">
<Columns>
<asp:BoundField HeaderText="Publisher" DataField="Publisher" />
<asp:TemplateField HeaderText="Books">
<ItemTemplate>
<asp:BulletedList ID="BulletedList1" runat="server"
DataSource='<% #Eval("Books") %>' DataValueField="Title" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
But that does not work and gives this error
{"Data source is an invalid type. It must be either an IListSource,
IEnumerable, or IDataSource."}
Although the ResultsView of the query in debug shows the correct entry
as
{ Publisher = "I Publisher", Books = {(no books)} }
thanks
Sunit
SQL:
from publisher in SampleData.Publishers
join book in SampleData.Books
on publisher equals book.Publisher into PublisherBooks
from book in PublisherBooks.DefaultIfEmpty(new Book { Title = "(no
books)" })
select new
{
Publisher = publisher.Name,
Books = book
};
The grid is defined as :
<asp:GridView ID="GridViewGroupJoin" AutoGenerateColumns="false"
runat="server">
<Columns>
<asp:BoundField HeaderText="Publisher" DataField="Publisher" />
<asp:TemplateField HeaderText="Books">
<ItemTemplate>
<asp:BulletedList ID="BulletedList1" runat="server"
DataSource='<% #Eval("Books") %>' DataValueField="Title" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
But that does not work and gives this error
{"Data source is an invalid type. It must be either an IListSource,
IEnumerable, or IDataSource."}
Although the ResultsView of the query in debug shows the correct entry
as
{ Publisher = "I Publisher", Books = {(no books)} }
thanks
Sunit