Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 584371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:53:27+00:00 2026-05-13T14:53:27+00:00

I have a dropdownlist that I already have manually databinding. I currently get the

  • 0

I have a dropdownlist that I already have manually databinding. I currently get the data, loop through each item, and depending on values in the item, change the css for the individual ListItem.

For example:

foreach (Site mySite in myList)
        {
            ListItem li = new ListItem(mySite.FullAddress, mySite.Id.ToString());
            if (mySite.DisabledFlg)
            {
                li.Attributes.Add("style", "color:#999");
            }
            this.Items.Add(li);
        }

I’m trying to force the text in the listitem to break at certain points. The string that I retrieve from the datasource currently has a “\r\n” everywhere where there should be a line break. This works fine for display in a normal textbox, but it doesn’t work on the listitem.
I’ve tried replacing the “\r\n” with a "<br>" but when I do that, it just displays <br> in the listem along with the rest of the text. I’ve tried wrapping the listitem contents in a "div" with a width attribute, but it also just display the "div" tag literally in the ListItem text.
I’ve also tried adding the following to the ListItem attributes at bind:

                li.Attributes.Add("width", "100px");

But that hasn’t resulted in any change either.

I’ve seen custom drop down list controls that have multiline listitems in them. How do I acheive the same result?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:53:27+00:00Added an answer on May 13, 2026 at 2:53 pm

    I don’t think this is possible. The DropDownList control renders a <select> element and it’s just not designed for its child <option> elements to have line breaks.

    Another way to achieve the same effect however would be to process your data before binding it to the DropDownList. You could split on the line feeds and just assign the same DataValue to those duplicated items. You would end up with HTML like the following:

    <select>
        <option value="A">A</option>
        <option value="A">A.2</option>
        <option value="B">B</option>
    </select>
    

    You might also be able to find some fancy Javascript controls or plug-ins that would simulate a dropdown control but allow you more flexibility than the plain select element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DropdownList that shows a list of providers & the Provider associated
I have a page that has a few textboxes and a dropdownlist. When a
Suppose i have a dropdownlist in which whole months are there in that dropdown.I
I want to have dropdownlist with months and years from some point in the
I have created a ASP.NET WebForms Gridview and I need to access each row
Note: I have a workaround to this problem, but I'd prefer to comma-separate the
I have a Jquery dialog with an ASP listview control inside. Before showing the
This is in ASP.NET. We are using a ExtJS frontend, and have our own
My issue is similar to How to use the Value of a Selected Value
In my current application I want to implement ASP.Net localization with global resources. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.