Hide Datagrid

G

Guest

Not sure if I'm in the right thread but here goes.

I have an ASP.Net web page with a datagrid. The code behind is C#.

If the datagrid has no records the datagrid header section is still shown.
What I need is to hide all of the datagrid if there are no records.
 
G

Guest

Yes. This is the code

if(ActiveDate != DateTime.Today.ToString()) {btnMyCompanyToday.Enabled =
true;}
lblWIOInfo.Text = "There is no data to display for Weekends or National
Holidays.";
lblWIOInfo.ForeColor = Color.DarkRed;
dgMyCompany.Visible = false;

I'm selecting a date from a calendar which normally populates the datagrid
correctly with people who are absent on the date.
If I select a weekend or holiday date, then the grid should not be visible,
however, the header can still be seen.
 
G

Guest

Sorry, that previous code does work correctly. The datagrid header shows if I
select a calendar date in the future where no records are present to display.
Is there someway to count the datagrid records and then hide the grid of the
count = 0?
 
G

Guest

Possibly there are two ways, your choice:

1. Check ( grid.VisibleRowCount==0 ) OR
2. Check ( grid.Items.Count==0 )

Steve
 

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

Top