开发者

check for the option label string

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜