How can I create a SelectList with multiple selected values?

前端 未结 3 902
日久生厌
日久生厌 2021-01-03 21:47

I\'m trying to set multiple values in a select list:

SelectList List = new SelectList(MyListItems, \"valField\", \"dataField\", );
         


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-03 22:46

    You want to use MultiSelectList instead which has a constructor to meet your needs:

    public MultiSelectList(
        IEnumerable items,
        string dataValueField,
        string dataTextField,
        IEnumerable selectedValues
    )
    

提交回复
热议问题