views:

125

answers:

1

I have this code:

Dim Result As New DataTable
DataAdapter.Fill(Result)


            'bind data to visible surname/name grid
            If Result.Rows.Count = 0 Then
                NoInputBottom.Text = "No Results. Please widen your search criteria and try again"
                NoInputTop.Text = "No Results. Please widen your search criteria and try again"
            Else
                GV.DataSource = Result
                GV.DataBind()
            End If

I have also tried moving the check to the gridview like so:

If GV.Columns.Count = 0 Then
                NoInputBottom.Text = "No Options Selected: Please select your search criteria and try again"
                NoInputTop.Text = "No Options Selected: Please select your search criteria and try again"
            End If

When I run the code. the noinput labels do not have value, the null check seems to be failing? Please can you tell me how to display a message if the search returned no reults.

A: 

This is a copy of my comment to the original question in order to be able to mark the question as answered (thank you Phil).

What does the debugger say about Result.Rows.Count (if you hover your mouse cursor over it)? This should bring you certainty about the seems to be failing, no? I mean you know then if Count is indeed not zero (for whatever reason) or if the text in the Labels (or whatever NoInputBottom is) gets overwritten later on or something similar.

scherand