No default member found for type "myClass" error, please help

R

Rob

Hi,

I have a collection object that I created that inherits from ArrayList.
I then add "Programme" objects to this collection and bind it to the
datagrid using the following code:

Dim oProgrammes As New Programmes
oProgrammes.GetAll()
grdDetails.DataSource = oProgrammes
grdDetails.DataBind()

This works fine and the records are displayed in the grid. My problem is
that when I try to add a link to the first column in the grid to allow
the user to select the row by clicking on the value in the first coulmn,
I get an error message saying:

No default member found for type 'Programme'

where 'Programme' is the name of the object in the oProgrammes
collection above.

Here's the code that I'm using for the grid:

<asp:DataGrid id="grdDetails" runat="server" AutoGenerateColumns="False"
CssClass="grid" Width="100%">
<Columns>
<asp:TemplateColumn HeaderText="Programme Name">
<ItemTemplate>
<%#NavigateURL(Container.DataItem("Id"),
Container.DataItem("Name"))%>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="GrantCount" HeaderText="Number of
Grants</asp:BoundColumn>
<asp:BoundColumn DataField="GrantValue" HeaderText="Value
(£)"</asp:BoundColumn>
</Columns>
</asp:DataGrid>


Here's the code for the NavigateURL function:

Function NavigateURL(ByVal ProgrammeId As Int32, ByVal ProgrammeName As
String) As String
Return "<a href='NewProgramme.aspx?ProgrammeId=" & ProgrammeId &
"'>" & ProgrammeName & "</a>"
End Function

Any help would be appreciated.

Rob
 
R

Rob

Hi,

I've sorted this now. I replaced the <asp:TemplateColumn> with an
<asp:HyperLinkColumn> instead and it now works fine with the arraylist.

Here's the new line for reference:

<asp:HyperLinkColumn
DataNavigateUrlField="Id"
DataTextField="Name"
DataNavigateUrlFormatString="ViewProgramme.aspx?ProgrammeId={0}"
HeaderText="Programme Name"
</asp:HyperLinkColumn>

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top