Then it's not your code - your code is the VB.NET code.
You presented us code which wouldn't compile. As you told us about
something failing *other* than compilation, that means the code you
presented wasn't the code you were trying to use.
Do you require paging?
So put it outside the DataContext - I'm afraid I don't see the problem
with doing so.
Unless I'm mistaken, you've told ASP.NET to try to find a method with
a parameter of type Object, not of type Tag. However, at this point
it's really an ASP.NET question more than LINQ - the LINQ side of
things is reasonably irrelevant. You might want to ask on the ASP.NET
newsgroup - particularly as there are more likely to be VB developers
there than here.
Jon
Hi Jon,
The moment I put it outside the DataContext I get the error:
ObjectDataSource 'ObjectDataSource1' could not find a non-generic
method 'GetTags' that has no parameters.
This is what is driving me crazy. I really don't see any reason why
this does not work.
Yes I need paging and that was why I am return the tags as a
Collection.
It is irrelevant to me if the help is in VB.NET or C#. I write in
VB.NET only because it is faster to me.
Here is my entire code. Maybe someone can see if I am doing something
wrong (I converter everything to C#):
MyPage.ASPX
<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="ListViewDesign.aspx.vb"
Inherits="ListViewDesign" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head runat="server">
<title>List View Design</title>
</head>
<body>
<form id="fListViewDesign" runat="server">
<asp:ListView ID="ListView1" runat="server"
DataSourceID="ObjectDataSource1" DataKeyNames="TagID"
InsertItemPosition="FirstItem">
<AlternatingItemTemplate>
<tr style="">
<td>
<asp:Label ID="TagText" runat="server" Text='<%#
Eval("Text") %>' />
</td>
<td>
<asp:LinkButton ID="EditButton" runat="Server" Text="Edit"
CommandName="Edit" />
<asp:LinkButton ID="DeleteButton" runat="Server"
Text="Delete" CommandName="Delete" />
</td>
</tr>
</AlternatingItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server"
border="0" style="">
<tr runat="server" style="">
<th runat="server">
Tag Text
</th>
<th runat="server">
Command
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
<asp
ataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button"
ShowFirstPageButton="True" ShowLastPageButton="True" />
</Fields>
</asp
ataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server"
CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server"
CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="TagTextTextBox" runat="server" Text='<%#
Bind("Text") %>' />
</td>
</tr>
</InsertItemTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:Label ID="TagText" runat="server" Text='<%#
Eval("Text") %>' />
</td>
</tr>
</SelectedItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
No data was returned.
</td>
</tr>
</table>
</EmptyDataTemplate>
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server"
CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server"
CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="TagTextTextBox" runat="server" Text='<%#
Bind("Text") %>' />
</td>
</tr>
</EditItemTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="TagText" runat="server" Text='<%#
Eval("Text") %>' />
</td>
<td>
<asp:LinkButton ID="EditButton" runat="Server" Text="Edit"
CommandName="Edit" />
<asp:LinkButton ID="DeleteButton" runat="Server"
Text="Delete" CommandName="Delete" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetTags" TypeName="LabDataContext">
</asp:ObjectDataSource>
</form>
</body>
</html>
MyPage.ASPX.VB
Imports System
Imports System.ComponentModel
Partial Class ListViewDesign
Inherits System.Web.UI.Page
' GetTags
<DataObjectMethodAttribute(DataObjectMethodType.Select, True)> _
Public Shared Function GetTags() As ICollection
' Create database
Dim database As New LabDataContext
' Select tags
Dim tags = From t In database.Tags _
Select t.TagID, _
t.Text, _
Active = t.ArticlesTags.Any
' Return tags
Return tags
End Function ' GetTags
End Class