拖曳下拉列表项 [英] Shuffling dropdownlist items

查看:86
本文介绍了拖曳下拉列表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在下拉列表中显示随机播放的项目.我将数据库中的动态项目绑定到dropdonlist.每当我打开该页面时,我需要的值应随机或随机出现.

I need to display shuffled items in a dropdownlist. I am binding dynamic items from database to dropdonlist..Whenever I opens that page I need values should appear shuffled or randomly..

推荐答案

您好,如果您使用MSSQL,这是您的解决方案:

SELECT column1,column2,column3
来自your_table
ORDER BY NEWID()
Hi, if you use MSSQL, here is your solution:

SELECT column1, column2, column3
FROM your_table
ORDER BY NEWID()


在其中随机播放DataRow DataTable [^ ]

在DB中,您可以使用RAND()
Shuffle DataRow in DataTable[^]

In DB you can use RAND()
SELECT * FROM TableName ORDER BY RAND()


如果您直接绑定到DataTable或其他来自数据库,则显示顺序(假设您尚未设置Sorted属性true)将始终是从数据库返回的显示顺序.在绑定数据之前,这里唯一的选择是将项目重新排序为新的结构(例如List< T>或and Array).

但是,为什么要随机分配用户数据-您可能会严重惹恼用户.就个人而言,如果列表不是按字母顺序排列的,那么我希望它以任务为中心的顺序排列,最常见的项目在顶部.如果这些随机地移动,我会很讨厌您的...
If you are binding directly to a DataTable or other source that comes from a database, then the display order (assuming that you have not set the Sorted property true) will always be that returned form the database. Your only option here is to re-order the items into a new structure (such as a List<T> or and Array) befiore you bind the data.

Why do you want to randomize user data though - you will probably seriously annoy your users. Personally, if a list is not alphabetical, then I expect it to be in a task-centric order, with most common items at the top. If these moved randomly, I would be quite peeved with you...


这篇关于拖曳下拉列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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