Lucky Luke2
Lucky Luke2

Reputation: 2116

Tooltip on asp:dropdown

I have a user control that loads a asp:dropdownlist via an asp:datasource: What i need to do is show a tooltip on each dropdown value.

Here is my code:

<asp:dropdownlist id="lstBusinessUnit" runat="server" 
                            appenddatabounditems="True"
                            width="200px" 
                            datasourceid="sqlBusinessUnit" 
                            datatextfield="sBusUnitDisplay" 
                            datavaluefield="sBusUnitCode"
                            >


 <asp:sqldatasource id="sqlBusinessUnit" runat="server" 
    connectionstring="<%$ ConnectionStrings:Database %>" 
    selectcommand="SELECT [sBusUnitCode],[sBusUnit], [sBusUnitDisplay] FROM [tBusinessUnits] ORDER BY [sBusUnitDisplay]" />

What i need is for sBunit to be the tooltip for each value. Please help. Thanks.

Upvotes: 0

Views: 87

Answers (1)

christof13
christof13

Reputation: 329

You should add an attribute title to each of your listitem in code behind

 foreach (ListItem item in lstBusinessUnit.Items)
 {
     item.Attributes.Add("Title", "your tooltip");
 }

Upvotes: 1

Related Questions