locked
how to shrink or hide row in a table where data is not displayed? RRS feed

  • Question

  • User-798868173 posted

    Hi all, I have a table which contains 3 rows. all the rows have either textboxes or radio button in it. In the second row of the table, there are 2 textboxes which are set to visible = false, 2 radio button one is Yes and one is NO if user were to click on the yes button the 2 textboxes will appear below and if user click on 2 this 2 boxes will dissappear. The problem is tad if the textboxes do not appear,the space where the textboxes are suppose to be are left empty. Is there anyway to make the row shrink instead of having this empy space? and same goes to row, is there any way to make the row invisble if no data is found in the row? Any help is greatly appreciated. Thanks

    Wednesday, January 14, 2009 9:07 PM

Answers

  • User1272541218 posted

    Hi,

     

    You have said text boxes should be hidden but there are no textboxes in your aspx. Any way I suppose that u mean DropDownList.

    the changed script will look some thing like this:Pay attention to the bolded and underlined part

    <tr>

    <td style="width: 185px; " colspan="0" valign="top" id="id1">

    <asp:Label ID="Label19" runat="server"

    Text="Receive Notice Of Arrival Fm Carrier:" Font-Names="Times New Roman"

    Font-Size="10pt" Width="223px"></asp:Label>

    </td>

    <td style="width: 118px; " id="Td1">

    <span style="text-decoration: underline">

    <table style="width: 170px; height: 22px">

    <tr>

    <td style="width: 100px">

    <asp:RadioButton ID="rdbarrive" runat="server" GroupName="arrive" Text="Yes" Width="81px"

    Font-Names="Times New Roman" Font-Size="9pt" AutoPostBack="True" /></td>

    <td style="width: 100px">

    <asp:RadioButton ID="rdbArrive2" runat="server" GroupName="arrive" Text="No" Width="81px"

    Font-Names="Times New Roman" Font-Size="9pt" AutoPostBack="True" /></td>

    </tr>

    </table>

    <table style="width: 100%" id="table1" runat="server">

    <tr>

    <td>

    <span style="text-decoration: underline">

    <table>

    <tr>

    <td style="width: 38px; height: 24px;">

    <asp:DropDownList ID="ddlArriveDay" runat="server" Width="42px"

    Font-Names="Times New Roman" Font-Size="9pt" Height="21px" Visible="False">

    <asp:ListItem></asp:ListItem>

    </asp:DropDownList>

    </td>

    <td style="width: 46px; height: 24px;">

    <asp:DropDownList ID="ddlArriveMonth" runat="server" Width="48px"

    Font-Names="Times New Roman" Font-Size="9pt" Height="21px" Visible="False">

    <asp:ListItem></asp:ListItem>

    </asp:DropDownList>

    </td>

    <td style="width: 55px; height: 24px;">

    <asp:DropDownList ID="ddlArriveYear" runat="server" Width="55px"

    Font-Names="Times New Roman" Font-Size="9pt" Height="21px" Visible="False">

    <asp:ListItem></asp:ListItem>

    </asp:DropDownList></td>

    </tr>

    </table>

    </span>

    </td>

    </tr>

    </table>

    </span></td>

    </tr>

     

    Now when the user clicks on radio buttons, as the autopost back is set to true, make this table visible true or false as shown below:

    table1.Visible=false;

    Hope it helps

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 16, 2009 1:33 AM

All replies

  • User-1171043462 posted

    If you are using asp table you can do this

    Table1.Rows(0).Visible = False

    Thursday, January 15, 2009 2:08 AM
  • User-798868173 posted

    i don't think it can work cause though i have declared the table as table1 i still get the same error msg saying that table1 is not declare. Is there any other solutions to that? Thanks 

    Thursday, January 15, 2009 7:38 PM
  • User-1171043462 posted

    i don't think it can work cause though i have declared the table as table1 i still get the same error msg saying that table1 is not declare. Is there any other solutions to that? Thanks 

     

    what type of Table it is if its HTML table then add runat = server to it

    and also for each TR tags you will have to give ID and runta = server so that you can use it server side

     

    Thursday, January 15, 2009 11:43 PM
  • User1272541218 posted

    Hi,

    Suppose the following is your table, jusr use the ids of the rows to hide or show them as and when required. By this u'll get rid of the extra space.

    <table>

    <tr runat="server" id="id1">

    <td>

     

    </td>

    </tr>

    <tr runat="server" id="id2">

    <td>

     

    </td>

    </tr>

    </table>

    Hope it helps.

    Friday, January 16, 2009 12:43 AM
  • User1272541218 posted

    Hi,

    Suppose the following is your table, jusr use the ids of the rows to hide or show them as and when required. By this u'll get rid of the extra space.

    <table>

    <tr runat="server" id="id1">

    <td>

     

    </td>

    </tr>

    <tr runat="server" id="id2">

    <td>

     

    </td>

    </tr>

    </table>

    Hope it helps.

     

    Friday, January 16, 2009 12:45 AM
  • User-798868173 posted

    sorry im a little slow in this kind of things

    so here is ma code

     <tr>
                <td style="width: 185px; " colspan="0" valign="top" id="id1">
                    <asp:Label ID="Label19" runat="server"
                        Text="Receive Notice Of Arrival Fm Carrier:" Font-Names="Times New Roman"
                        Font-Size="10pt" Width="223px"></asp:Label>
                    </td>
                <td style="width: 118px; " id="id1">
                    <span style="text-decoration: underline">
                    <table style="width: 170px; height: 22px">
                        <tr>
                            <td style="width: 100px">
                    <asp:RadioButton ID="rdbarrive" runat="server" GroupName="arrive" Text="Yes" Width="81px"
                                    Font-Names="Times New Roman" Font-Size="9pt" AutoPostBack="True" /></td>
                            <td style="width: 100px">
                    <asp:RadioButton ID="rdbArrive2" runat="server" GroupName="arrive" Text="No" Width="81px"
                                    Font-Names="Times New Roman" Font-Size="9pt" AutoPostBack="True" /></td>
                        </tr>
                    </table>
                    <table style="width: 100%">
                        <tr>
                            <td>
                    <span style="text-decoration: underline">
                    <table>
                        <tr>
                            <td style="width: 38px; height: 24px;">
                    <asp:DropDownList ID="ddlArriveDay" runat="server" Width="42px"
                        Font-Names="Times New Roman" Font-Size="9pt" Height="21px" Visible="False">
                        <asp:ListItem></asp:ListItem>
                    </asp:DropDownList>
                            </td>
                            <td style="width: 46px; height: 24px;">
                    <asp:DropDownList ID="ddlArriveMonth" runat="server" Width="48px"
                        Font-Names="Times New Roman" Font-Size="9pt" Height="21px" Visible="False">
                        <asp:ListItem></asp:ListItem>
                    </asp:DropDownList>
                            </td>
                            <td style="width: 55px; height: 24px;">
                    <asp:DropDownList ID="ddlArriveYear" runat="server" Width="55px"
                        Font-Names="Times New Roman" Font-Size="9pt" Height="21px" Visible="False">
                        <asp:ListItem></asp:ListItem>
                    </asp:DropDownList></td>
                        </tr>
                    </table>
                    </span>
                            </td>
                        </tr>
                    </table>
                    </span></td>
            </tr>

    where should i place the coding that u guys specify then? thanks 

    Friday, January 16, 2009 1:14 AM
  • User1272541218 posted

    Hi,

     

    You have said text boxes should be hidden but there are no textboxes in your aspx. Any way I suppose that u mean DropDownList.

    the changed script will look some thing like this:Pay attention to the bolded and underlined part

    <tr>

    <td style="width: 185px; " colspan="0" valign="top" id="id1">

    <asp:Label ID="Label19" runat="server"

    Text="Receive Notice Of Arrival Fm Carrier:" Font-Names="Times New Roman"

    Font-Size="10pt" Width="223px"></asp:Label>

    </td>

    <td style="width: 118px; " id="Td1">

    <span style="text-decoration: underline">

    <table style="width: 170px; height: 22px">

    <tr>

    <td style="width: 100px">

    <asp:RadioButton ID="rdbarrive" runat="server" GroupName="arrive" Text="Yes" Width="81px"

    Font-Names="Times New Roman" Font-Size="9pt" AutoPostBack="True" /></td>

    <td style="width: 100px">

    <asp:RadioButton ID="rdbArrive2" runat="server" GroupName="arrive" Text="No" Width="81px"

    Font-Names="Times New Roman" Font-Size="9pt" AutoPostBack="True" /></td>

    </tr>

    </table>

    <table style="width: 100%" id="table1" runat="server">

    <tr>

    <td>

    <span style="text-decoration: underline">

    <table>

    <tr>

    <td style="width: 38px; height: 24px;">

    <asp:DropDownList ID="ddlArriveDay" runat="server" Width="42px"

    Font-Names="Times New Roman" Font-Size="9pt" Height="21px" Visible="False">

    <asp:ListItem></asp:ListItem>

    </asp:DropDownList>

    </td>

    <td style="width: 46px; height: 24px;">

    <asp:DropDownList ID="ddlArriveMonth" runat="server" Width="48px"

    Font-Names="Times New Roman" Font-Size="9pt" Height="21px" Visible="False">

    <asp:ListItem></asp:ListItem>

    </asp:DropDownList>

    </td>

    <td style="width: 55px; height: 24px;">

    <asp:DropDownList ID="ddlArriveYear" runat="server" Width="55px"

    Font-Names="Times New Roman" Font-Size="9pt" Height="21px" Visible="False">

    <asp:ListItem></asp:ListItem>

    </asp:DropDownList></td>

    </tr>

    </table>

    </span>

    </td>

    </tr>

    </table>

    </span></td>

    </tr>

     

    Now when the user clicks on radio buttons, as the autopost back is set to true, make this table visible true or false as shown below:

    table1.Visible=false;

    Hope it helps

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 16, 2009 1:33 AM
  • User-1171043462 posted

    Simply give ID and add runat= "server"

     To hide Row Or Cell

     <tr runat = "server" id = "Row1">
                            <td style="width: 100px" id = "Row1Cell1" runat = "server">
                    <asp:RadioButton ID="rdbarrive" runat="server" GroupName="arrive" Text="Yes" Width="81px"
                                    Font-Names="Times New Roman" Font-Size="9pt" AutoPostBack="True" /></td>
                            <td style="width: 100px">
                    <asp:RadioButton ID="rdbArrive2" runat="server" GroupName="arrive" Text="No" Width="81px"
                                    Font-Names="Times New Roman" Font-Size="9pt" AutoPostBack="True" /></td>
    </tr>

    in Code

    Row1.Visible = False

    Row1Cell1.Visible =False

    Friday, January 16, 2009 1:47 AM