为多列表框中的每个选定项目实现循环

时间:2016-10-12 19:01:32

标签: c# sql vb.net loops listbox

我正在尝试为多列表框foreach中的每个所选项目实施UserProfileTrainingSearch循环:

if (UserProfileTrainingSearch.SelectedValue != "-1" && //other conditions)
{
    foreach (var ListBoxItem in UserProfileTrainingSearch.SelectedValue) // only the first item selected is giving the results.
    {
        Session["UserbyTrainingType"] = "SELECT DISTINCT USERPROFILE.USER_ISN, USERPROFILE.LAST_NAME + ',' ..........................;
        SqlUserProfile.SelectCommand = (string)Session["UserbyTrainingType"];
    }
}

1 个答案:

答案 0 :(得分:0)

foreach (ListBoxItem item in UserProfileTrainingSearch.SelectedItems)
{
   // your code here
}