I am having an issue with a search page. By the gridview will only bind and be displayed if there are record matching a user's search term. When are no results or no gridview is displayed I would like to display a label say something like "No results found" but no matter where I put my if statement below the label does not show up.
For example, I'll use this in various gvwSearchResult events with no effect:
if( gvwSearchResults.Rows.Count <= 0)
{
lblNoResults.Visible = true;
}
Here is some of my code behind:
protected void Button1_Click(object sender, EventArgs e)
{
CISSoftwareList softwareList;
int selection = Convert.ToInt32(ddlSelection.SelectedValue);string searchTerm = txtSearch.Text;
softwareList =
CISSoftwareDB.GetCISSoftwareListBySearch(searchTerm, selection);System.Threading.Thread.Sleep(700);
gvwSearchResults.DataSource = softwareList;
gvwSearchResults.DataBind();
}
protected void gvwSearchResults_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover",
"this.originalcolor=this.style.backgroundColor;" + " this.style.backgroundColor='#ecf6fb';");e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;");
}
}