asp.net checkboxlist text not next to checkbox?

2.8k Views Asked by At

I cannot figure out how to force the asp.net checkListBox text to be next to (horizontally) the checkboxes ?

Meaning, they text shows up BELOW the checkbox... There is plenty of room in the width to accomodate the text, why does it drop it down underneath ?

it is defined like so;

<asp:CheckBoxList 
ID="CheckBoxList1" 
runat="server" 
Width="665px" 
Font-Size="7pt" 
Font-Bold="False"
CellPadding="1"
CellSpacing="1"
RepeatColumns="1"
RepeatDirection="Vertical"
RepeatLayout="Table"
TextAlign="Right">
</asp:CheckBoxList>

I thought TextAlign="Right" should do this... But I get this instead:

checkbox alignment

2

There are 2 best solutions below

0
On

Try setting your repeat layout to something other than table, such as flow. Something funky could be going on with those tables (something in your css, etc). I like to avoid html tables wherever I can that isn't displaying tabular data.

<asp:CheckBoxList 
  ID="CheckBoxList1" 
  runat="server" 
  Width="665px" 
  Font-Size="7pt" 
  Font-Bold="False"
  RepeatDirection="Vertical"
  RepeatLayout="Flow"
  TextAlign="Right">
</asp:CheckBoxList>
0
On

There are two methods I’ve found on other forum pages: Force a style update by putting the following above the CheckBoxList:

<style type="text/css">
    label { display: inline-block; }
</style>

Another method worked on one project, and for some reason, not on another – so this may or may not work: Add to your stylesheet:

.checkboxlist_nowrap label
{
    display:inline;
}

The add to your checkbox list tag:

<asp:CheckBoxList ... CssClass="checkboxlist_nowrap" >