开发者

check for the option label string

开发者 https://www.devze.com 2023-01-28 03:34 出处:网络
I\'m using the option Label string for my Html.DropDownList but my datasource is a SelectList. How I would check for the option label back on the server? The backing type for the variable is an EnumTy

I'm using the option Label string for my Html.DropDownList but my datasource is a SelectList. How I would check for the option label back on the server? The backing type for the variable is an EnumType. I inspected the value and it says 0 but it won't let me check for 0.

Than开发者_开发知识库ks, rod.


How about casting the value back to the enum type on the server:

[HttpPost]
public ActionResult Index(int selectedValue)
{
    MyEnum label = (MyEnum)selectedValue;
    ...
}


You can't. Labels aren't posted with the form. You'll need to place the value in a <input type="hidden"> if you want the value.

0

精彩评论

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