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 UpdatePlayer_Click(object sender, EventArgs e) { string name = UpdateName.Text; string email = UpdateEmail.Text; string pName = DropDownListPlayers.SelectedItem.ToString(); List <string> nList = client.UpdatePlayer(name + " " + email + " " + pName).Split('*').ToList <string>(); DropDownListPlayers.DataSource = nList; DropDownListPlayers.DataBind(); }
protected void DeletePlayer_Click(object sender, EventArgs e) { try { string pName = DropDownListPlayers.SelectedItem.ToString(); List <string> nList = client.DeletePlayer(pName).Split('*').ToList <string>(); DropDownListPlayers.DataSource = nList; DropDownListPlayers.DataBind(); } catch (Exception ex) { Panel2.Visible = false; Response.Write(ex.ToString()); } }