Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Razor converting enum to int inside a view

I a razor view .I have line like bleow

<option value='@{(Int16)PhoneType.Work}'>@PhoneType.Work</option> 

This is an option in a select list/dropdownlist In this I have an enum PhoneType. For text filed @PhoneType.Work works fine but for value field @{(Int16)PhoneType.Work is not working

What can i do to get integer value of the enum at value field

like image 922
Kuttan Sujith Avatar asked Nov 15 '12 11:11

Kuttan Sujith


1 Answers

This syntax should do the trick (note the () instead of {}):

<option value='@( (Int16) PhoneType.Work )'>@PhoneType.Work</option> 
like image 172
Stéphane Bebrone Avatar answered Sep 28 '22 10:09

Stéphane Bebrone