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

Discussion in 'ASP .Net Datagrid Control' started by Rob, Jan 14, 2005.

  1. Rob

    Rob Guest

    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









    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Rob, Jan 14, 2005
    #1
    1. Advertising

  2. Rob

    Rob Guest

    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

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Rob, Jan 14, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Eshtry
    Replies:
    2
    Views:
    4,315
    Teemu Keiski
    Feb 14, 2004
  2. Mario Fratelli
    Replies:
    32
    Views:
    1,389
    Phlip
    Dec 9, 2003
  3. Dave
    Replies:
    1
    Views:
    351
    Ron Natalie
    Dec 8, 2003
  4. modemer
    Replies:
    11
    Views:
    642
    modemer
    Mar 21, 2005
  5. Andy Eshtry

    Error: No default member found for type MyClass

    Andy Eshtry, Feb 13, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    199
    Andy Eshtry
    Feb 13, 2004
Loading...

Share This Page