如何按字母顺序排列两个不同 CheckBoxList 中的项目?
我有两个复选框(推荐和其他),其中包含人员姓名(串联,即约翰·史密斯是一项)。我想将每个列表中选定的成员按字母顺序排列为一个。我该怎么做?
I have two checkboxes (Recommended and Others) which have peoples names (concatenated, i.e. John Smith is one item). I want to alphabetize the selected members of each list into one. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
具有三个复选框列表控件(chkRecommended、chkOthers、chkCombined)的 ASP.NET 实现
如果您只是指值列表而不是另一个控件,则可以修改我提供的原始查询或像这样扩展它
An ASP.NET implementation with three checkboxlist controls (chkRecommended, chkOthers, chkCombined)
If you just meant a list of the values rather than another control, you can modify the original query I provided or extend it like so
您可以将两者的选定成员放入字符串列表中并排序,然后将字符串列表放入新的 CheckBoxList 中。
请参阅 http://msdn.microsoft.com/en-us/library/b0zbh7b6 .aspx 用于 MSDN List(T).Sort Method 示例。
You can put the selected members of both into a List of strings and sort, then put the list of strings into a new CheckBoxList.
See http://msdn.microsoft.com/en-us/library/b0zbh7b6.aspx for the MSDN List(T).Sort Method example.
如果您从 SqlDataSource 获取它们,为什么不通过 SQL 按字母顺序排列呢?
If you're grabbing them from a SqlDataSource, why not do the alphabetizing via SQL?