Datagrid empty data hides header

Discussion in 'ASP .Net Web Controls' started by Roby Eisenbraun Martins, Dec 9, 2005.

  1. 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
     
    Roby Eisenbraun Martins, Dec 9, 2005
    #1
    1. Advertising

  2. 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
     
    Phillip Williams, Dec 9, 2005
    #2
    1. Advertising

  3. I missed the line that checks for the dataview is null, e.g.

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


    "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
     
    Phillip Williams, Dec 9, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Reb
    Replies:
    3
    Views:
    3,179
    Anthony Williams
    Nov 27, 2003
  2. Wayne Brantley

    hides inherited member ApplicationInstance

    Wayne Brantley, Dec 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    6,946
    Steven Cheng[MSFT]
    Dec 19, 2005
  3. Replies:
    6
    Views:
    5,112
  4. Beauregard T. Shagnasty

    IE hides inline images with opaque background

    Beauregard T. Shagnasty, Dec 31, 2004, in forum: HTML
    Replies:
    13
    Views:
    915
  5. mlt
    Replies:
    2
    Views:
    880
    Jean-Marc Bourguet
    Jan 31, 2009
Loading...

Share This Page