添加行ASP.NET到列表框 [英] Adding line to ASP.NET to ListBox

查看:132
本文介绍了添加行ASP.NET到列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要添加到ASP.NET列表框,提供从许多选项,用户可以从中选择一些分离线。目前,我们对用户超过20个不同的选项可供选择,我需要把最流行的往上顶。我有一个放流行的选择之上的逻辑,但想在列表框中一个行会帮助用户从列表的其余部分分开。列表框的项目中填充后面的code。

I need a line added to a listbox in ASP.NET to provide some separation from the many options the user can choose from. Currently, we have over 20 different options for the user to choose and I need to put the most popular up top. I have the logic that puts the popular option on top, but think a line in the listbox will help the user separate them from the rest of the list. The listbox items are populated in the code behind.

推荐答案

您可以使用OPTGROUP标签给分离。

You can use the optgroup tag to give separation.

<select>
   <option value="XX"/>
   <optgroup label="separation"/>
   <option value="BB"/>
</select>

要只给出一条线,你需要做一些挂羊头卖狗肉。见下面

To give only a line you will need to do some trickery. See below

<style type="text/css">
    optgroup {border-bottom:solid thin black; width:100%;}
</style>
<select>
   <option value="XX"/>
   <optgroup label=" "/>
   <option value="BB"/>
</select>

如果您的数据已经被加载,你可以运行后,一些jQuery。

If your data is already loaded you could run some jquery after.

$('select option[value="XX"]').after('<optgroup label=""/>');

这篇关于添加行ASP.NET到列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆