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 8610343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:06:31+00:00 2026-06-12T04:06:31+00:00

I’m working on an older ASP.NET project (not MVC I don’t think) and one

  • 0

I’m working on an older ASP.NET project (not MVC I don’t think) and one of the features they require is to view a description of an item when they hover over that item in a dropdown list. This can be simply done with HTML using the following code and making use of title text:

<select>
    <option value="1" title="Option 1 Desc">Option 1</option>
    <option value="2" title="Option 2 Desc">Option 2</option>
    <option value="3" title="Option 3 Desc">Option 3</option>
</select>

Ok so how do I do this using ASP.NET DropDownList control? I have the following code:

<asp:DropDownList ID="DropDownListLocation" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownListLocation_OnSelectedIndexChanged" CssClass="editorFieldServerControl" ClientIDMode="Static"></asp:DropDownList>

And in the ‘code behind’ page:

private void PopulateFacilityDropdown(List<FacilityAvailableByLocation> facilities, int? selectedID)
{
    DropDownListFacility.DataSource = facilities;
    DropDownListFacility.DataTextField = "FacilityName";
    DropDownListFacility.DataValueField = "FacilityID";
    DropDownListFacility.DataBind();            
    DropDownListFacility.Items.Insert(0, new System.Web.UI.WebControls.ListItem("", ""));                   

    if (selectedID.HasValue && selectedID.Value > 0)
        DropDownListFacility.SelectedIndex = facilities.FindIndex(b => b.FacilityID == selectedID.Value);
        else DropDownListFacility.SelectedIndex = 0;
    }
}

Basically each facility in the list of facilities there has properties for an ID, Name, Description that I can get out. I just want to be able to put a title attribute on each <option> that gets rendered and put the description into it. Either that or be able to add a custom attribute like ‘data-description’ to each <option> tag then I can add the title into each option tag myself using a bit of jQuery which is easy enough.

I miss the days where you could just loop through a list and output the custom dropdown code manually.

Any ideas? Many thanks

  • 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-06-12T04:06:33+00:00Added an answer on June 12, 2026 at 4:06 am

    You can manually add a title attribute to each list item like this. Give it a shot:

        private void PopulateFacilityDropdown(List<FacilityAvailableByLocation> facilities, int? selectedID)
        {
            DropDownListFacility.DataSource = facilities;
            DropDownListFacility.DataTextField = "FacilityName";
            DropDownListFacility.DataValueField = "FacilityID";
            DropDownListFacility.DataBind();            
            DropDownListFacility.Items.Insert(0, new System.Web.UI.WebControls.ListItem(String.Empty, String.Empty);                   
    
            foreach (FacilityAvailableByLocation f in facilities)
            {
                DropDownListFacility.Items.FindByValue(f.FacilityID).Attributes.Add("title", f.TitleDescription);
            }
    
            if (selectedID.HasValue && selectedID.Value > 0)
                DropDownListFacility.SelectedIndex = facilities.FindIndex(b => b.FacilityID == selectedID.Value);
                else DropDownListFacility.SelectedIndex = 0;
            }
        }
    

    f.TitleDescription would be the property you want the title to be.

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

Sidebar

Related Questions

I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I have a view passing on information from a database: def serve_article(request, id): served_article
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.