Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MVC
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.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 2:27am

1 solution

Rate this: bad
good
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">
            <asp:ListItem>1</asp:ListItem>
            <asp:ListItem>2</asp:ListItem>
            <asp:ListItem>3</asp:ListItem>
            <asp:ListItem>4</asp:ListItem>
            <asp:ListItem>5</asp:ListItem>
        </asp:DropDownList>
 

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]);
        }
    }
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 240
1 Kamal Rocks 184
2 BillWoodruff 173
3 PIEBALDconsult 160
4 CPallini 155
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,180


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2014
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