Gridview Footer not showing

Last post 09-28-2007 9:36 AM by RedSunBeer. 3 replies.

Sort Posts:

  • Gridview Footer not showing

    05-17-2006, 2:14 PM
    • Member
      417 point Member
    • mru22
    • Member since 08-05-2005, 2:43 PM
    • Posts 118

    I am not sure if this is by design but when I bind a datasource that has no records or objects in a collection then the gridview's footer does not display.  I know in the datagrid I could still have a footer display if there were not items in the datagrid.

    Is there a work around or some way I can get the footer to display even if I have no items in the Gridview.  I have showfooter set to true.

    Thanks,

  • Re: Gridview Footer not showing

    05-17-2006, 3:40 PM
    • Star
      11,530 point Star
    • jcasp
    • Member since 04-10-2003, 10:43 AM
    • Posts 2,286
    It is by design (bad design perhaps?).  GridView no longer displays the header/footer when there's no data to display.  There's EmptyDataText and EmptyDataRowStyle which can be used to display something pertinent when no data is found.  I rather liked the DataGrid's behavior when it comes to dealing with empty data.
  • Re: Gridview Footer not showing

    05-17-2006, 5:03 PM
    • Member
      411 point Member
    • AmNoGeek
    • Member since 04-04-2006, 2:31 PM
    • Posts 96
    It sure is bad design, but the EmptyDataText does not solve the problem either. It would simply display whatever text you define but will still not show the footer.
    You will have to insert an empty object in the datasource (in case your datasource count is 0) and then on RowDataBound event hide this empty row. It is not a very good solution but a decent hack that works.

  • Re: Gridview Footer not showing

    09-28-2007, 9:36 AM
    • Member
      14 point Member
    • RedSunBeer
    • Member since 01-16-2003, 6:59 PM
    • Bangalore
    • Posts 4

    Gridview doesnt allow the footer to display if there are no records in its datasource.  So first add a dummy/empty but valid row/record/value to the gridview datasource before assigning and binding it to the gridview.  Then set the first row of the gridview to invisible.  An example is given below,

    /* 

    DataRow dr = dataView.Table.NewRow();

    dataView.Table.Rows.Add(dr);

    grd.DataSource = dataView;

    grd.DataBind();

    grd.Rows[0].Visible = false;

    */

    Good luck - redsunbeer

    Cheers,
    RSB
Page 1 of 1 (4 items)