[英]Set selected values in asp ListBox with one line
I'm trying to set the selected values in an asp ListBox
webcontrol from a string[]
but I'm getting the error 我正在尝试从
string[]
在asp ListBox
Web ListBox
设置选定的值,但出现错误
Only assignment, call, decrement, increment and new object expressions can be used as a statement Here's what I have so far...
只能将赋值,调用,减量,增量和新对象表达式用作语句。这是到目前为止我所拥有的...
string[] pageRoles = new string[] {"Admin", "Users", "Publisher"};
pageRoles.ToList().ForEach(r => rolesListBox.Items.FindByValue(r).Selected == true);
I believe the problem is you were using a comparison operator instead of assignment. 我相信问题是您使用的是比较运算符而不是赋值。
string[] pageRoles = new string[] {"Admin", "Users", "Publisher"};
pageRoles.ToList().ForEach(r => rolesListBox.Items.FindByValue(r).Selected = true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.