Click here to Skip to main content
13,054,615 members (48,424 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I’m using a custom dropdownlist and binding elements dynamically, but here I want to show a tooltip message on every items of dropdown list.

View Code:
@Html.DropDownListFor(m => m.Industry,Model.IndustryList, "All", new { @style = "width:258px;", @class = "drpDown" })
Controller code:
IEnumerable<SelectListItem> IndustryList= EntityModel<t>.Where(m => m.t == “something”).ToList().Select(c => new SelectListItem { Text = t.Name, Value = t.Value);

So let me know is there any way to set title on every option items within select tag.
Posted 25-Feb-13 1:27am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

try this may be it will help you.
remember it is only a concept to Show tooltip(or title) message on every dropdown list items,
modify it as your requirement.

aspx code

<asp:DropDownList ID="DropDownList1" runat="server">

cs code

protected void Page_Load(object sender, EventArgs e)
        string[] ar = new string[5];
        ar[0] = "One"; ar[1] = "Two"; ar[2] = "Three"; ar[3] = "Four"; ar[4] = "Five";
        for (int i = 0; i < DropDownList1.Items.Count - 1; i++)
            DropDownList1.Items[i].Attributes.Add("title", ar[i]);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100