views:

69

answers:

3

i have a Gridview that has filters that can fire off the emptydata template. However when this is displayed I can still see the outline of my gridview. How can I make the Gridview disappear when the data is not present?

A: 

Hide the control itself with the Visible property set to false, or hide its parent control (i.e. the containing panel).

jscharf
sounds great...but how can i do that in code and where? Gridview databound? how can i get access to the emptydata template in code?
Eric
GridView is an ASP.NET control, which means it will have a 'Visible' property, allowing you to show or hide the control itself.GridView.Visible = false;will prevent the control from being rendered at all.
jscharf
+4  A: 
protected void GridView1_DataBound(object sender, EventArgs e)
{
    if (this.GridView1.Rows.Count == 0)
      this.GridView1.Visible = false; 
}
JBrooks
What i wanted was for the Gridview borders to be hidden. Databoud was the correct place to do it. Thank you
Eric
+1  A: 
<asp:Gridview id="gridview" ...... 
      Visible='<%# ((ICollection)gridview.DataSource).Count == 0 ? false : true %>'>
ghills