protected void Page_Load(object sender, EventArgs e) { client = new ServiceReference1.Service1Client(); try { if (!Page.IsPostBack) { this.DropDownListPlayers.SelectedIndexChanged -= new System.EventHandler(DropDownListPlayers_SelectedIndexChanged); this.DropDownListGames.SelectedIndexChanged -= new System.EventHandler(DropDownListGames_SelectedIndexChanged); List <string> nList = client.getAllPlayersNames().ToList <string>(); DropDownListPlayers.DataSource = nList; DropDownListPlayers.DataBind(); List <string> gList = client.getAllGamesForCombo().ToList <string>(); DropDownListGames.DataSource = gList; DropDownListGames.DataBind(); this.DropDownListPlayers.SelectedIndexChanged += new System.EventHandler(DropDownListPlayers_SelectedIndexChanged); this.DropDownListGames.SelectedIndexChanged += new System.EventHandler(DropDownListGames_SelectedIndexChanged); } } catch (Exception ex) { Panel2.Visible = false; Response.Write(ex.ToString()); } }
protected void DeleteGame_Click(object sender, EventArgs e) { try { string gameId = ((DropDownListGames.SelectedItem).ToString().Split(' '))[0].ToString(); client.DeleteGame(gameId); List <string> gList = client.getAllGamesForCombo().ToList <string>(); DropDownListGames.DataSource = gList; DropDownListGames.DataBind(); GridView1.DataSource = null; GridView1.DataBind(); } catch (Exception ex) { Panel2.Visible = false; Response.Write(ex.ToString()); } }