locked
Get rid of empty space between rows RRS feed

  • Question

  • User1888449941 posted

     I have created a table that has 50 rows, each row contains a GridView control that may or may not show depending on wether it has information to retrieve from the database. My problem is that if Gridviews on rows 2 and 40 are the only ones displaying, I end up having this dead space between the two GridViews, how can I get rid of this. Every gridview MUST be in their own cell.

    Sunday, May 10, 2009 11:32 PM

Answers

All replies

  • User-1179452826 posted

    You can try setting the table's cellpadding=0 and cellspacing=0. But ideally, you should use css to position the gridviews. Here's a quick css layout tutorial:

    http://www.barelyfitz.com/screencast/html-training/css/positioning/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 11, 2009 12:59 AM
  • User1343415737 posted

    how do you set the visibility of the gridview? .visible = false? thinking of probably if the rows's gridview is empty, set the display fo the row (<tr id="tr1" runat="server">) to none

    Monday, May 11, 2009 1:39 AM
  • User-852894958 posted

    Hi beleami,

    Try this

    <table  align="center" cellpadding="0" cellspacing="0" width="100%">
    <tr>
     <td>
     <asp:Panel ID="pnlGridView1" runat="server"  Width="100%" visible="false">
      <asp:GridView ID="GridView1" runat="server">
      </asp:GridView>
     </asp:Panel>
     <asp:Panel ID="pnlGridView2" runat="server"  Width="100%" visible="false">
      <asp:GridView ID="GridView2" runat="server">
      </asp:GridView>
     </asp:Panel>
     </td>
    </tr>
    </table>

     

    Thanks,

    Farooq

    Monday, May 11, 2009 2:18 AM
  • User-14001990 posted

    Hi,

    You could have a asp table with each row being a server control.Give an id to each row of the table.

    Then hide that row like this:

    row1.Visible = false;

    Hope it helps.

    Monday, May 11, 2009 6:16 AM
  • User-1293249277 posted

     well from client side u can do like this

    var oTR = document.getElementById("urTRToBeHiddent");
        if(oTR .style.display == '')
        {
        oTR.style.display = 'none';

    coz as far as i know if u make visible fasle the controls fromthe server side... then the hight of the 'control hidden -TR' remain there and it occups the space...!

     

    still can u place ur rendered page's HTML over here.?
     

     

    Monday, May 11, 2009 6:58 AM
  • User377791177 posted

    put this quick javascript at the bottom of the page

    <script>

    var table = document.getElementById('50 row table id' );

    var i=0;

    for(;i<table.rows.length;i++)

    {

       if (table.rows[i].children.length <= 1) //IF ROW HAS CHILDREN LENGTH WILL BE AT LEAST 1

      {

          table.rows[i].style.display='none';

      }

    }

    </script>

    Monday, May 11, 2009 7:36 AM
  • User44917808 posted

    hi 

    I am using scroll bar in panel control and attached grid view .

    but there is gap between panel and grid view.

    how to fix  this gap.


    Thanks

    Saturday, December 11, 2010 4:29 AM