The value of Online,Tele and Physical in DB with int datatype. In Edit View i want to checked the radiobutton which have the value 1 in db. The AppointCat is random property in model. I used this long if else condition in my Edit View. How i improve my code or is there any other way to write this code:
@if (Model.ApOnline == 1)
{
<span>
Online: @Html.RadioButtonFor(x => x.AppointCat, "Online", new { @checked = true })
</span>
<span>
TeleMed: @Html.RadioButtonFor(x => x.AppointCat, "TeleMed")
</span>
<span>
Physical: @Html.RadioButtonFor(x => x.AppointCat, "Physical")
</span>
}
else if (Model.ApTele == 1)
{
<span>
Online: @Html.RadioButtonFor(x => x.AppointCat, "Online")
</span>
<span>
TeleMed: @Html.RadioButtonFor(x => x.AppointCat, "TeleMed", new { @checked = true })
</span>
<span>
Physical: @Html.RadioButtonFor(x => x.AppointCat, "Physical")
</span>
}
else
{
<span>
Online: @Html.RadioButtonFor(x => x.AppointCat, "Online")
</span>
<span>
TeleMed: @Html.RadioButtonFor(x => x.AppointCat, "TeleMed")
</span>
<span>
Physical: @Html.RadioButtonFor(x => x.AppointCat, "Physical", new { @checked = true })
</span>
}
You can understand from my code that i am noob in MVC. Thanks for the help in advance