protected void ResultsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { PlaceHolder PlaceHolder1 = (PlaceHolder)e.Item.FindControl("PlaceHolder1"); // declare/obtain the value of i given the DataItem // e.g., TableHockeyContestRound m_round = (TableHockeyContestRound)e.Item.DataItem; for (int m_nCurrentTableNumber = 1; m_nCurrentTableNumber <= m_nMaxNumberOfConcurrentGames; m_nCurrentTableNumber++) { List <TableHockeyGame> m_gamesOnCurrentTable = m_round.TableHockeyGame.Where(g => g.TableNumber == m_nCurrentTableNumber).ToList(); if (m_gamesOnCurrentTable.Count > 0) { TableHockeyContestRound m_roundGame = new TableHockeyContestRound(); Mapper.Map(m_round, m_roundGame); m_roundGame.TableHockeyGame = m_gamesOnCurrentTable; uc.ucEndGameSeries uc = (uc.ucEndGameSeries)LoadControl("~/uc/ucEndGameSeries.ascx"); uc.InitControl(m_roundGame); uc.m_nTableNumber = m_nCurrentTableNumber; PlaceHolder1.Controls.Add(uc); } } } }
private void SaveEnteredGameResults() { //Get results for each end game uc and update TableHockeyGame table. PlaceHolder PlaceHolder1 = (PlaceHolder)Page.Controls[0].FindControl("form1").FindControl("mainContent").FindControl("resultsRepeater").Controls[1].FindControl("PlaceHolder1"); for (int jCount = 0; jCount < PlaceHolder1.Controls.Count; jCount++) { uc.ucEndGameSeries ucCurrentEndGameSeries = (uc.ucEndGameSeries)PlaceHolder1.Controls[jCount]; ucCurrentEndGameSeries.getUCGUI(); for (int iCount = 0; iCount < ucCurrentEndGameSeries.m_games.Count; iCount++) { int currentHomeScoreEntered = ucCurrentEndGameSeries.m_games[iCount].HomePlayerScore; int currentAwayScoreEntered = ucCurrentEndGameSeries.m_games[iCount].AwayPlayerScore; int m_nCurrentGameId = ucCurrentEndGameSeries.m_games[iCount].GameId; int m_nCurrentHomePlayerId = ucCurrentEndGameSeries.m_games[iCount].HomePlayerId; int m_nCurrentAwayPlayerId = ucCurrentEndGameSeries.m_games[iCount].AwayPlayerId; bool m_bHasSuddenDeath = ucCurrentEndGameSeries.m_games[iCount].hasSuddenDeath; using (var context = new TableHockeyData.UHSSWEB_DEVEntities()) { var querySingleGame = context.TableHockeyGame.First(g => g.GameId == m_nCurrentGameId); TableHockeyGame m_currentGame = (TableHockeyGame)querySingleGame; m_currentGame.HomePlayerScore = currentHomeScoreEntered; m_currentGame.AwayPlayerScore = currentAwayScoreEntered; m_currentGame.hasSuddenDeath = m_bHasSuddenDeath; m_currentGame.HomePlayerId = m_nCurrentHomePlayerId; m_currentGame.AwayPlayerId = m_nCurrentAwayPlayerId; context.SaveChanges(); } } } }