Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.1
This is the forum to discuss the Wrox book Beginning ASP.NET 1.1 with Visual C#.NET 2003 by Chris Ullman, John Kauffman, Chris Hart, Dave Sussman, Daniel Maharry; ISBN: 9780764557088
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 3rd, 2004, 04:45 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default Chapter 10 Error

Hi there,

I am working my way through the ASP.NET VB version and I cant find whats going wrong. I keep getting this error....

Server Error in '/' Application.
--------------------------------------------------------------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'DataItem' is not a member of 'System.Web.UI.Control'.

Source Error:



Line 90: <asp:Repeater id="PlayersList" runat="server" />
Line 91: <ItemTemplate>
Line 92: <asp:linkbutton text='<%# Container.DataItem("PlayerName") %>' style="color:darkred" runat="server" width="120" />
Line 93: &nbsp;&nbsp;
Line 94: <asp:label text='<%# Container.DataItem("PositionName") %>' id="playerposition" runat="server" /><br />


Source File: C:\BegASPNet11\WroxUnited\Teams.aspx Line: 92


*****************************************

This is the code that I am using.....

<%@ Page Language="VB" %>
<script runat="server">

    Dim SelectedTeam As String

    Sub Page_Load()
        TeamList.DataSource = GetTeams
        TeamList.DataBind()
    End Sub

    Sub TeamList_ItemCommand(sender As Object, e As DataListCommandEventArgs)

        If e.CommandName.equals("ShowTeam") Then
            SelectedTeam = CType(e.CommandSource, LinkButton).Text
            PlayersList.DataSource = GetPlayersByTeam(e.CommandArgument)
            PlayersList.DataBind()
        End If
    End Sub

        Function GetTeams() As System.Data.IDataReader
            Dim connectionString As String = ConfigurationSettings.AppSettings("ConnectionStrin g")
            Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )

            Dim queryString As String = "SELECT [Teams].[TeamID], [Teams].[TeamName], [Teams].[Notes] FROM [Teams]"
            Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
            dbCommand.CommandText = queryString
            dbCommand.Connection = dbConnection

            dbConnection.Open
            Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)

            Return dataReader
        End Function


        Function GetPlayersByTeam(ByVal teamID As Integer) As System.Data.IDataReader
            Dim connectionString As String = ConfigurationSettings.AppSettings("ConnectionStrin g")
            Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )

            Dim queryString As String = "SELECT [Players].[PlayerName], [Positions].[PositionName] FROM [Players], [Positi"& _
    "ons], [PlayerTeam], [Teams] WHERE (([PlayerTeam].[PlayerID] = [Players].[PlayerI"& _
    "D]) AND ([PlayerTeam].[Position] = [Positions].[PositionID]) AND ([PlayerTeam].["& _
    "TeamID] = [Teams].[TeamID]) AND ([PlayerTeam].[TeamID] = @TeamID))"
            Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
            dbCommand.CommandText = queryString
            dbCommand.Connection = dbConnection

            Dim dbParam_teamID As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
            dbParam_teamID.ParameterName = "@TeamID"
            dbParam_teamID.Value = teamID
            dbParam_teamID.DbType = System.Data.DbType.Int32
            dbCommand.Parameters.Add(dbParam_teamID)

            dbConnection.Open
            Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)

            Return dataReader
        End Function

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <h1>Wrox United
        </h1>
        <h2>Teams
        </h2>
        <p>
            <table>
                <tbody>
                    <tr>
                        <td>
                            <asp:DataList id="TeamList" runat="server" OnItemCommand="TeamList_ItemCommand">
                                <ItemTemplate>
                                    <asp:linkbutton text='<%# Container.DataItem("TeamName") %>' CommandArgument='<%# Container.DataItem("TeamID") %>' id="TeamNameLink" style="color:darkred" CommandName="ShowTeam" runat="server" />
                                    <br />
                                    <asp:Label text='<%# Container.DataItem("Notes") %>' id="teamnotes" runat="server" />
                                </ItemTemplate>
                                <SeparatorTemplate>
                                    <br />

                                </SeparatorTemplate>
                            </asp:DataList>
                        </td>
                        <td>
                        </td>
                       <td style="vertical-align:top">
                            <asp:Repeater id="PlayersList" runat="server" />
                                <ItemTemplate>
                                    <asp:linkbutton text='<%# Container.DataItem("PlayerName") %>' style="color:darkred" runat="server" width="120" />
                                &nbsp;&nbsp;
                                    <asp:label text='<%# Container.DataItem("PositionName") %>' id="playerposition" runat="server" /><br />
                                </ItemTemplate>
                            <headerTemplate>
                                Players in: <%= SelectedTeam %>

                            </headerTemplate>
                            <footerTemplate>

                            </footerTemplate>
                            </asp:Repeater>
                        </td>
                    </tr>
                </tbody>
            </table>

        </p>
    </form>
</body>
</html>


__________________
David Jenkins
 
Old June 4th, 2004, 06:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Try:

Databinder.Eval(Container.DataItem, "PlayerName")

Brian
 
Old June 5th, 2004, 05:57 AM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default

Nope still gives me...

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'DataItem' is not a member of 'System.Web.UI.Control'.

Source Error:



Line 90: <asp:Repeater id="PlayersList" runat="server"></asp:Repeater>
Line 91: <ITEMTEMPLATE>
Line 92: <asp:linkbutton id="LinkButton1" style="COLOR: darkred" runat="server" width="120" text='<%# Databinder.Eval(Container.DataItem, "PlayerName") %>'></asp:linkbutton>
Line 93: &nbsp;&nbsp; <asp:Label id="playerposition" runat="server" text='<%# Container.DataItem("PositionName") %>'></asp:Label>
Line 94: <br />


Source File: C:\BegASPNet11\WroxUnited\Teams.aspx Line: 92


 
Old June 5th, 2004, 01:56 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default

To check wether it was something wrong with my code or i ran the code that is in the downloads. that code ran perfectly.... so then i pain stakingly went through to see if there were any differences. the only real differences that i can see is capitals and lowercase differences. but these run right the way through out the code and i thought that it would be correct in the book DataItem rather than dataitem..... could that affect it?

cheers
dave.

 
Old June 7th, 2004, 09:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

VS.NET would have reformatted DataItem to the correct casing if it could have.. so I suspect there's some other problem with the code if id didn't ake that chage. I'd suspect a missplaced quote or something like that.


Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 10 exception error JohnBoy BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 4 August 1st, 2007 03:27 PM
Chapter 10 Hit Counter Error villager BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 April 23rd, 2006 06:04 AM
Chapter 10, Try It Out error, page 380 VictorVictor BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 2 February 13th, 2006 12:41 PM
Chapter 10 system exception error dkelly BOOK: Beginning VB.NET Databases 1 July 28th, 2005 04:07 AM
error found Chapter 10 pg 439 dogfish227 BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 1 April 8th, 2004 01:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.