labels in checkboxlist wrapping, why?

Posted on 2005-03-10
Medium Priority
Last Modified: 2008-01-09
On two different .aspx pages I have checkboxlist controls.  On both pages I databind the list to to the results of query and all works, except that on 1 page the labels on the checkboxes in the list wrap, but not on the other one?!?!

How do you prevent the text from wrapping?  I can't find a property anywhere....why would one wrap and the other not?

Question by:backwaterdogs
LVL 11

Expert Comment

ID: 13513518
Can you post the code?


Accepted Solution

mppeters earned 2000 total points
ID: 13517850
There's no real simple way to prevent it from wrapping, since for some silly reason, you can't set a cssclass for each ListItem in a RadioButtonList.

One workaround I can think of is to set a cssclass for the entire radiobuttonlist and have css do the rest of the work to find the <label> tag for each radiobutton.

For example:
<asp:radiobuttonlist id="YesNoRBL" runat="server" cssclass="inputlist" repeatdirection="Horizontal"      cellpadding="0" cellspacing="0">
<asp:listitem value="N">No</asp:listitem>
<asp:listitem value="Y">Yes</asp:listitem>

Then in your style sheet:

.inputlist {
   /* nothing really needed here */
.inputlist label {
      white-space: nowrap;

And just for good measure:
If you want to eliminate extra padding if your radiobuttonlist is contained within a parent table. You can do this:

.inputlist input {
         width: 15px;
      height: 15px;
      margin: 2px 2px 2px 0px;
      padding: 0;
      vertical-align: middle;

.inputlist label {
      margin-right: 4px;
      white-space: nowrap;

Expert Comment

by:Joel Parmer
ID: 20732827
Awesome!  Thanks.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question