|
Subject:
|
Ch-10 "Teams.aspx", repeater not rendered.
|
|
Posted By:
|
jyotsna
|
Post Date:
|
9/25/2004 11:29:49 AM
|
Hi,
I am working out on the examples given in the book. this problem occured in Ch-10 and in the Teams.aspx page.
When i am clicking on the Team A/Team B, the repeater control should display the players in the team. but nothing comes up. i don't know where the problem is.. because i have typed the same code given in the book. can anyone suggest where the problem could be.......?
thank you jyo
|
|
Reply By:
|
stu9820
|
Reply Date:
|
9/27/2004 7:10:39 AM
|
Can you post your code?
|
|
Reply By:
|
jyotsna
|
Reply Date:
|
9/27/2004 8:51:32 AM
|
Hi, i am including the code for the problem on Ch-10.(TeamA/TeamB)
<%@ Page Language="VB" %> <script runat="server">
dim SelectedTeam as String 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 GetPlayersByTeam(ByVal teamID As Integer) As System.Data.IDataReader Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\BegASPNET11\"& _ "wroxUnited\Database\WroxUnited.mdb" Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString) Dim queryString As String = "SELECT [Players].[PlayerName], [Positions].[PositionName], [PlayerTeam].[TeamID] "& _ "FROM [Players], [Positions], [PlayerTeam], [Teams] WHERE (([PlayerTeam].[PlayerI"& _ "D] = [Players].[PlayerID]) AND ([PlayerTeam].[TeamID] = [Teams].[TeamID]) AND (["& _ "PlayerTeam].[Position] = [Positions].[PositionID]) 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.CommandBehavior.CloseConnection) Return dataReader End Function Sub Page_Load() TeamList.DataSource = GetTeams() TeamList.DataBind() End Sub Function GetTeams() As System.Data.IDataReader Dim connectionString As String = _ "provider=Microsoft.jet.OLEDB.4.0; Ole Db Services=-4;" & _ " Data Source= C:\BegASPNET11\wroxUnited\Database\WroxUnited.mdb" 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.CommandBehavior.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 /> <hr color="#b0c4de" width="250px" /> </SeparatorTemplate> </asp:DataList> </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" /> <asp:Label text='<%# Container.dataitem("PositionName") %>' id="Playerposition" runat="server" /> <br /> </ItemTemplate> <headerTemplate> Players in: <%= SelectedTeam %> <hr color="#b0c4de" width="200px" /> </headerTemplate> <FooterTemplate> <hr color="#b0c4de" width="200px" /> </FooterTemplate> </asp:Repeater> </td> </tr> </tbody> </table> <!-- Insert content here --> </p> </form> </body> </html>
|