【发布时间】:2015-10-28 06:58:04
【问题描述】:
有谁知道如何设置asp 下拉列表的样式?下拉菜单的箭头很难更改,最初是这样的:
有没有人有任何解决方案来修复或设置这个 asp 下拉列表的样式?
这是我的代码:(我无法将其更改为选择下拉列表,因为我的下拉列表选项是根据列表框中的选择动态填充的)
ASP 文件
<asp:DropDownList ID="NewDropDownList" runat="server" Width="136px"
OnSelectedIndexChanged="jobRun_SelectedIndexChanged" AutoPostBack="True" >
</asp:DropDownList>
cs文件
public void BindNewDropDownList()
{
//Lost to hold the values
List<DateTime> listCopy = new List<DateTime>();
DateTime dt;
string values = String.Join(", ", JOBRUN_CBL.Items.Cast<ListItem>().Where(i => i.Selected).Select(i => i.Text));
if (values.Contains("Select All"))
{
//Loop through each items in listbox and then add it to list
foreach (ListItem li in ListBox1.Items)
{
if (DateTime.TryParse(li.Text, out dt))
{
listCopy.Add(dt);
}
}
}
else
{
//Loop through each items in listbox and then add it to list
foreach (ListItem li in ListBox1.Items)
{
//check if item is selected
if (li.Selected == true)
{
//add items to list
listCopy.Add(DateTime.Parse(li.Text));
}
}
}
//compare and sort so that the latest date comes on top
listCopy.Sort((x, y) => y.CompareTo(x));
//clear the items in dropdownlist
NewDropDownList.Items.Clear();
//set the datasource to dropdownlist
NewDropDownList.DataSource = listCopy;
//set the dateformatstring in dropdownlist
NewDropDownList.DataTextFormatString = "{0:dd-MMM-yyyy}";
//Bind the dropdownlist
NewDropDownList.DataBind();
}
请帮助我解决这个问题已经有一段时间了,但仍然找不到装饰它的方法。
谢谢。
【问题讨论】:
-
你想为“下拉”改变什么?你有箭头的图片吗?
-
嗨@Nic,我正在尝试更改asp下拉列表的背景色和箭头。这只是关于如何更改 ddl 的背景色和箭头的一般问题。可以是这样的箭头的任何箭头图像:i.stack.imgur.com/y1T4N.gif。谢谢!
-
那么我认为重复的链接会帮助你..
标签: javascript c# css asp.net dropdown