This is a migrated thread and some comments may be shown as answers.

kendo radio button

1 Answer 570 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sanjay
Top achievements
Rank 1
sanjay asked on 13 Sep 2015, 09:01 PM

I've following code in razor view. How do I use Kendo Radio button to render the same? I'm struggling to assign enum to radio button value.

@if (Model == declaredEnum.​Val1) //declaredEnum is Enum
{
    @Html.RadioButtonFor(l => l, (int)declaredEnum.​Val1, new { @checked = "checked" });
    
}
else
{
    @Html.RadioButtonFor(l => l, (int)declaredEnum.​Val1);   
}
@Html.LabelFor(l => l, "Label")​

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 16 Sep 2015, 07:45 AM
Hello,

I am not sure why is the condition needed but the equivalent code to the one that you are currently using would be:
@if (Model == declaredEnum.Val1) //declaredEnum is Enum
{   
    @Html.Kendo().RadioButtonFor(l => l).Value((int)declaredEnum.Val1).Checked(true);
     
}
else
{
    @Html.Kendo().RadioButtonFor(l => l).Value((int)declaredEnum.Val1)
}

If the problem is with setting the enumeration value and not its corresponding integer value then please update to the latest service pack. There was an issue with outputting enumeration values that was already fixed.

Regards,
Daniel
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
sanjay
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or