Model Binding
You can bind a Telerik UI RadioButton to a model.
-
Create a new action method and pass the instance of the model to the View.
public class RadioButtonModel { public bool IAgreeProp { get; set; } } public partial class ButtonController : Controller { public ActionResult RadioButton() { RadioButtonModel myModel = new RadioButtonModel() { IAgreeProp = false }; return View(myModel); } }
-
Make your view strongly typed.
@model Kendo.Mvc.Examples.Controllers.RadioButtonModel
-
Add two RadioButtons and set the Boolean values for the checked state through the
.Value
setting. The matched Boolean value from model will define the initial checked state.The following example demonstrates how the radio button with the I Disagree label will be checked because its false value matches the model value.
@(Html.Kendo().RadioButtonFor(m => m.IAgreeProp).Label("I Agree").Value(true)) @(Html.Kendo().RadioButtonFor(m => m.IAgreeProp).Label("I Disagree").Value(false))