protected void btnBrowseCriteria_Click(object sender, EventArgs e) { TravelImageCollection col = new TravelImageCollection(); if (rbContinent.Checked) { col.FetchForContinent(Convert.ToString(ddlBrowseCriteria.SelectedValue), true); } if (rbCountry.Checked) { col.FetchForCountry(Convert.ToString(ddlBrowseCriteria.SelectedValue), true); } gvImage.DataSource = col; gvImage.DataBind(); }
/// <summary> /// Retrieves and binds data from search /// </summary> private void FetchSearchResults() { bool imgAscend = radImageAscend.Checked; bool postAscend = radPostAscend.Checked; if (radByImage.Checked) { _TICollection = new TravelImageCollection(); pnlImage.Visible = true; if (radCity.Checked) { //Fetch Images for city selected _TICollection.FetchForCity(Convert.ToInt32(drpCity.SelectedValue), imgAscend); } else if (radCountry.Checked) { //Fetch images for country selected _TICollection.FetchForCountry(drpCountry.SelectedValue, imgAscend); } else { //Fetch Images for by text search _TICollection.FetchLikeTitle(txtSearch.Text, imgAscend); } } else if (radByPost.Checked) { //Fetch posts for search term _TPCollection = new TravelPostCollection(); _TPCollection.FetchLikeTitle(txtSearch.Text, postAscend); pnlPost.Visible = true; } else { _TICollection = new TravelImageCollection(); _TPCollection = new TravelPostCollection(); //Fetch posts for search term _TPCollection.FetchLikeTitle(txtSearch.Text, postAscend); //Fetch images for search term _TICollection.FetchLikeTitle(txtSearch.Text, imgAscend); pnlImage.Visible = true; pnlPost.Visible = true; } //Make sure there is a collection if (_TPCollection.Count > 0) { gvPost.DataSource = _TPCollection; gvPost.DataBind(); } else { lbPosts.Text = "Sorry, no search results found for posts."; gvPost.DataSource = _TPCollection; gvPost.DataBind(); } if (_TICollection.Count > 0) { gvImage.DataSource = _TICollection; gvImage.DataBind(); } else { lbImages.Text = "Sorry, no search results found for images."; gvImage.DataSource = _TICollection; gvImage.DataBind(); } }