protected void ButtonSearch_Click(object sender, EventArgs e) { try { using (SBEntities db = new SBEntities()) { int systemID = int.Parse(DropDownListSystem.SelectedValue); string platform = db.GameSystems.Where(w => w.GameSystemKey == systemID).FirstOrDefault().GameDBPlatformID; string search = "http://thegamesdb.net/api/GetGamesList.php?name=" + HttpUtility.UrlEncode(TextBoxSearch.Text) + "&platform=" + HttpUtility.UrlEncode(platform); MemoryStream stream = new MemoryStream(); XmlTextWriter writer = new XmlTextWriter(stream, Encoding.UTF8); XmlDocument doc = new XmlDocument(); doc.Load(search); List <GameDBGamesListResult> searchResults = new List <GameDBGamesListResult>(); XmlNodeList games = doc.SelectNodes("Data/Game"); foreach (XmlNode result in games) { GameDBGamesListResult game = new GameDBGamesListResult(); game.Title = result.SelectSingleNode("GameTitle").InnerText; game.ReleaseDate = result.SelectSingleNode("ReleaseDate").InnerText; game.id = result.SelectSingleNode("id").InnerText; searchResults.Add(game); } RepeaterResults.DataSource = searchResults; RepeaterResults.DataBind(); } } catch (Exception ex) { SetError("There was an error searching GameDb.net. This happens from time to time, you might want to search again.<br/><br/>" + ex.Message); } }
protected void ButtonSearch_Click(object sender, EventArgs e) { try { listResults = rcontroller.getListResults(DropDownListAirports.SelectedItem.Text, DropDownListRAirports.SelectedItem.Text); RepeaterResults.DataSource = listResults; RepeaterResults.DataBind(); } catch (Exception exc) { if (Page.IsPostBack) { LiteralEroor.Text = "No result found!"; } } }