Null/Empty DataGrid Comparison

R

Ron

I've got a page that does reports, which pulls a dataGrid
from a SQL table. Sometimes there are no results for the
report, so I added a textbox that says "No results found".
Depending on whether or not there are results, I'd hide or
unhide the textbox. The only problem is that I can't
successfully do the check to see if the dataGrid/Set/Table
is null.

I tried this:

if( dataGrid1 == null) and this if (dataTable == null) and
a whole bunch of other variants


Is there something wrong with that statement? What's the
proper way to check if the dataGrid is null?
 
R

Ron

The number of rows returned was 0, but it still didn't
work. I just modified the if statement to say if the
number of rows returned was 0, then give the error. Thanks
for the help!
 
E

Eliyahu Goldin

You should check the number of rows in the DataTable:
dataTable.Rows.Count

BTW, a textbox is not the best choice for displaying a static message. Label
is better.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,818
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top