Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

empty gridview

Status
Not open for further replies.

mrp9090

Programmer
May 22, 2006
71
GB
I have a gridview and label that I only want to show if there are any records in the gridview, if there are no records to show I want them to both be invisible. Given that I'm not using any code for my gridview only declaring it within the ASP, how do I do this?
 
You could check the number of records in the datasource on the load of the page


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Figured it out myself :

if (GridView1.Rows.Count == 0)
{
GridView1.Visible = false;
GridView2.Visible = false;
lblTitle.Visible = false;
lblSummary.Visible = false;
}
else
{
GridView1.Visible = true;
GridView2.Visible = true;
lblTitle.Visible = true;
lblSummary.Visible = true;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top