Home All Groups Group Topic Archive Search About

Datagrid empty data hides header

Author
9 Dec 2005 5:19 PM
Roby Eisenbraun Martins
Hi,

     I have a gridview (NET 2005) and when it hasn't got values it shows a
nice "Not found" text message. But unfortunately all the gridview lay-out
hides( header, ... ).
     Is there a property to keep the gridview visible even if the data is
empty?

     Thank you,
     Roby Eisenbraun Martins

Author
9 Dec 2005 6:41 PM
Phillip Williams
Hi Roby,

I found in both ASP.NET 1.1 and 2.0 that you cannot do that except by having
another table (with its visible attribute set to false) on the page then upon
databinding you would set visible = true when the datasource is null, e.g.

protected void GridView1_DataBinding(boject sender, EventArgs e)
{
   GridView gv= (GridView)sender;
  DataView dv = (DataView)gv.DataSource; 
  //if you are using a Business Logic Layer then replace the prevous line with
  //equivalent type casting
  MyEmptyTable.visible=true;   //this is the table that you left to display
if there were no data

}

Show quoteHide quote
"Roby Eisenbraun Martins" wrote:

>      Hi,
>
>      I have a gridview (NET 2005) and when it hasn't got values it shows a
> nice "Not found" text message. But unfortunately all the gridview lay-out
> hides( header, ... ).
>      Is there a property to keep the gridview visible even if the data is
> empty?
>
>      Thank you,
>      Roby Eisenbraun Martins
Author
9 Dec 2005 6:46 PM
Phillip Williams
I missed the line that checks for the dataview is null, e.g.

if (dv == null) {
  MyEmptyTable.Visible=true;
  GridView1.Visible = false;
}


Show quoteHide quote
"Phillip Williams" wrote:

> Hi Roby,
>
> I found in both ASP.NET 1.1 and 2.0 that you cannot do that except by having
> another table (with its visible attribute set to false) on the page then upon
> databinding you would set visible = true when the datasource is null, e.g.
>
> protected void GridView1_DataBinding(boject sender, EventArgs e)
> {
>    GridView gv= (GridView)sender;
>   DataView dv = (DataView)gv.DataSource; 
>   //if you are using a Business Logic Layer then replace the prevous line with
>   //equivalent type casting
>   MyEmptyTable.visible=true;   //this is the table that you left to display
> if there were no data
>
> }
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Roby Eisenbraun Martins" wrote:
>
> >      Hi,
> >
> >      I have a gridview (NET 2005) and when it hasn't got values it shows a
> > nice "Not found" text message. But unfortunately all the gridview lay-out
> > hides( header, ... ).
> >      Is there a property to keep the gridview visible even if the data is
> > empty?
> >
> >      Thank you,
> >      Roby Eisenbraun Martins