开发者

get selectlist first value in my controller

开发者 https://www.devze.com 2022-12-20 03:26 出处:网络
I just po开发者_JS百科pulated my SelectList variable inside my controller. Is there a way to get the first value of the selectlist into another variable?

I just po开发者_JS百科pulated my SelectList variable inside my controller. Is there a way to get the first value of the selectlist into another variable?

thanks, rod.


You can use the ElementAt extension method (need using System.Linq)

var firstElement = selectList.Items.ElementAt(0);
0

精彩评论

暂无评论...
验证码 换一张
取 消