Hi,
I'm having some problems with using a label to display a message "No Records Found" when the user clicks a Search button. What I want it to do is to check if there are any results from a database that get displayed on a GridView. I have the following method so far:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Protected Sub SearchBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SearchBtn.Click
If GridView1.Rows.Count = 0 Then
NoRecords.Visible = True
Else
NoRecords.Visible = False
GridView1.DataBind()
End If
End Sub
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
GridView1 is self explanatory, and "NoRecords" is the ID of the label. I initially set it to false in the properties in the default.aspx page, and what I want to do is:
- when the page loads, label doesn't display all
- if the user enters a search and it returns a result and the gridview displays and has more than 0 rows, then the label stays invisible
- if the user enters a search and it can't find anything, then set the label to visible with the message desired.
- If the user then enters another search which gives more than 0 results, make the label disappear again.
Can anyone help as this is driving me a little mad! 
Thanks,
Tom