我想把Table单元格里面的控件按顺序水平排列,但是控件却垂直排列很纠结

解决方案 »

  1.   

    不知道是说的是不是这个意思,看下面代码,然后你放你的button1_OnClick里面试一试。
    (手敲代码,不过应该没问题。)  TableRow r = new TableRow();
            TableCell c = new TableCell();
            r = new TableRow();
            Button b1 = new Button();
            b1.Width = 40;
            b1.Height = 20;
            b1.Text = "bt1";
            c.Controls.Add(b1);
            r.Cells.Add(c);
            c.Controls.Add(new LiteralControl("99"));
            r.Cells.Add(c);
            Button b2 = new Button();
            b2.Height = 20;
            b2.Width = 40;
            b2.Text = "bt2";
            c.Controls.Add(b2);
            r.Cells.Add(c);
            c.Controls.Add(new LiteralControl("99"));
            r.Cells.Add(c);
            Table1.Controls.Add(r);
      

  2.   

    单元格里的控件?  可以把控件放到<div>里  然后设置<div style="float:left">应该可以水平排列了
      

  3.   

    你是不是TABLE单元格嵌套错了?我给你看的那个,怎么都是一行排列的呀。你查一下,或者把部分代码贴上来。
      

  4.   


     <style   type= "text/css "> 
            .e{POSITION:relative;} 
            .ee{LEFT:80px;top:0px;POSITION:absolute;} 
            .elarge{LEFT:140px;top:0px;POSITION:absolute;}
        </style> 
      <table id="Table1" border="0" cellpadding="1" cellspacing="1" width="780px" 
                                    style="table-layout:fixed">
     <td style="width: 25%; text-align: right;" bgcolor="#E0E0E0">
                    是否自动续签
                </td>
                <td align="left" class="style1" colspan="3">
                <div class="e">
                    <asp:RadioButtonList ID="rdoLstisContinue" runat="server" RepeatDirection="Horizontal">
                        <asp:ListItem Value="0">否</asp:ListItem>
                        <asp:ListItem Value="1">是, 自动续签</asp:ListItem>
                    </asp:RadioButtonList>
                    <div class="elarge">
                        <asp:TextBox ID="txtContinueYear" runat="server" Width="54px"></asp:TextBox>
                        年
                    </div>
                </div>
                </td>
            </tr>
     </table>
      

  5.   

    你在<table>后加个<tr>,使控件在一行里面,
      

  6.   


      <table id="Table1" border="0" cellpadding="1" cellspacing="1" width="780px"   style="table-layout:fixed" bgcolor =yellow>
      <tr> <td style="width: 25%; text-align: right;" bgcolor="#E0E0E0"> 是否自动续签 </td>
      <td align="left" class="style1"  width =50%>       
                    <asp:RadioButtonList ID="rdoLstisContinue" runat="server" RepeatDirection="Horizontal" >
                        <asp:ListItem Value="0">否</asp:ListItem>
                        <asp:ListItem Value="1">是, 自动续签</asp:ListItem>
                    </asp:RadioButtonList>
       </td>         
       <td>                <asp:TextBox ID="txtContinueYear" runat="server" Width=20%></asp:TextBox>     年</td> 
           </tr></table>