简体   繁体   English

使用linq C#从逗号分隔的字符串中设置列表框的选定值

[英]Setting selected value of a list box from a comma-separated string using linq C#

I have a selection pop up in which user select his criteria from various list boxes, once he close the popup, if user closes Pop up and it returns to main screen, again if he needs to change some other filters he wants to see previous selected items from those listboxes. 我有一个选择弹出窗口,用户可以从各个列表框中选择条件,一旦他关闭了弹出窗口,如果用户关闭了“弹出窗口”并返回到主屏幕,那么他又需要更改一些其他过滤器以查看以前的选择这些列表框中的项目。 I am doing it by using Session values which contain comma-separated selected values and setting them by using for loop. 我通过使用包含逗号分隔的选定值的Session值并使用for循环来设置它们来做到这一点。 I want to know is there any best way to do it instead of For loop, which helps in increase of performance? 我想知道有什么最佳方法可以代替For循环,这有助于提高性能? Please I need your kind suggestions on this. 请我对此提出您的建议。

Thank you, 谢谢,

Sharath Sharath

It is not completely clear where you are going but from what I understand you have a list of options that are stored in csl, and these need to populate the list box. 目前尚不清楚要去哪里,但据我了解,您有一个存储在csl中的选项列表,这些选项需要填充列表框。 The quick answer is don't store data that way but rather make a class with the data and a list of objects to store the data. 快速的答案是不要那样存储数据,而是使用数据和要存储数据的对象列表创建类。 After that sorting or selecting the data to show is not a problem using the Select function in Linq... 之后,使用Linq中的选择功能排序或选择要显示的数据就不成问题了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM