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
2009-08-21 21:01:27
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
2009-08-21 21:03:03
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
2009-08-21 21:31:35
+4
A:
protected void GridView1_DataBound(object sender, EventArgs e)
{
if (this.GridView1.Rows.Count == 0)
this.GridView1.Visible = false;
}
JBrooks
2009-08-21 21:15:17
What i wanted was for the Gridview borders to be hidden. Databoud was the correct place to do it. Thank you
Eric
2009-08-21 21:46:42
+1
A:
<asp:Gridview id="gridview" ......
Visible='<%# ((ICollection)gridview.DataSource).Count == 0 ? false : true %>'>
ghills
2009-08-21 21:28:39