Listbox in asp.net not getting selected items

前端 未结 5 1092
花落未央
花落未央 2021-01-14 10:41

I have multiple dropdown & listbox in my webpage.

I am trying to get a list of CategoryID from a lstCatID listbox i am able to populate

5条回答
  •  渐次进展
    2021-01-14 11:32

    I am not sure what is wrong with the logic i am using.

    I came across a nice solution using LINQ.

    This single statement works great & gets me the desired results.

    string values = String.Join(", ", lstCatID.Items.Cast().Where(i => i.Selected).Select(i => i.Value).ToArray());
    

    RESULT: 3,29,25

提交回复
热议问题