Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I created one dropdown control in asp.net for that drop down value I added dynamically. I want to set background image and hover color all those things how to do?

What I have tried:

<asp:TableCell ColumnSpan="2" Style="padding-left: 30px; padding-bottom: 20px;">
                                            <asp:DropDownList runat="server" ID="ddlshopname" CssClass="PMSdropdown">


C#
DataTable dtprojects = new DataTable();
           dtprojects.TableName = "Project";
           DataColumn dcproject = new DataColumn();
           dcproject.DataType = Type.GetType("System.String");
           dcproject.ColumnName = "shopId";
           dtprojects.Columns.Add(dcproject);

           dcproject = new DataColumn();
           dcproject.DataType = Type.GetType("System.String");
           dcproject.ColumnName = "Shopname";
           dtprojects.Columns.Add(dcproject);

           DataRow drprojects = dtprojects.NewRow();
           drprojects = dtprojects.NewRow();
           drprojects["shopId"] = "1";
           drprojects["Shopname"] = "Shop1";
           dtprojects.Rows.Add(drprojects);

           drprojects = dtprojects.NewRow();
           drprojects["shopId"] = "2";
           drprojects["Shopname"] = "Shop2";
           dtprojects.Rows.Add(drprojects);

           ddlshopname.DataSource = dtprojects;
           ddlshopname.DataTextField = "Shopname";
           ddlshopname.DataValueField = "shopId";

           ddlshopname.DataBind();
Posted
Updated 23-Oct-16 19:49pm

1 solution

Quote:
I want to set background image and hover color.

You can use CSS to do that.
HTML
<style type="text/css">
    option:hover{
         background-color:black;
         /*background-image: url("paper.gif"); haven't tried it yet*/
         color:white}
</style>


Hope, it helps :)
 
Share this answer
 
Comments
MalathiMals 24-Oct-16 2:14am    
no i didn't get
Suvendu Shekhar Giri 24-Oct-16 2:21am    
Do you know CSS?
MalathiMals 24-Oct-16 2:36am    
see what i tried......


<asp:DropDownList runat="server" ID="ddlshopname" CssClass="PMSdropdown">


.PMSdropdown {
height: 39px;
width: 316px;
background: transparent;
color: gray;
padding-left: 10px;
font-size: 14px;

background-image: url(Images/arrow.png);
background-repeat: no-repeat;
background-position: 40px;
-webkit-background-clip: padding-box;
}

.PMSdropdown option {
background-color: #4D4D4D;
color: #969696;
padding-left: 50px;
font-size: 14px;
height:50px;
}

option:hover{
color:#fcb316;
}


thats all but hover color i did't get

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900