public void SelectListIndex(ListControl lc,string values)
{
string[] tempValues = values.Split(',');
if (tempValues.Length > 0)
{
foreach (string tempvalue in tempValues)
foreach (ListItem li in lc.Items)
{
if (li.Value == tempvalue)
li.Selected = true;
}
}
}
{
string[] tempValues = values.Split(',');
if (tempValues.Length > 0)
{
foreach (string tempvalue in tempValues)
foreach (ListItem li in lc.Items)
{
if (li.Value == tempvalue)
li.Selected = true;
}
}
}
本文介绍了一种方法,用于根据给定的值列表自动设置列表控件(如下拉列表)中项的选中状态。这种方法适用于需要批量设置列表项选中情况的场景,提高了开发效率。
166

被折叠的 条评论
为什么被折叠?



