Telerik Forums
UI for ASP.NET MVC Forum
1 answer
65 views

I have a grid doing edit  in a popup. When the popup shows it binds from my model to the fields  and all the fields bind and return their data back to the controller for Add/Update except for the RadioGroup it always returns null. It binds fine, just not returns any value to the Controller.

I tried the below:

@(Html.Kendo().RadioGroupFor(model => model.Sex)
                .Name("Sex1")
                .HtmlAttributes(new { style = "width:200px;", @class = "RequiredField" })
                .Layout(RadioGroupLayout.Horizontal)
                .Items(m =>
                {
                    m.Add().Label("Male").Value("Male");
                    m.Add().Label("Female").Value("Female");
                    m.Add().Label("N.A.").Value("N.A.");
                })           

)

I also tried using javascript to force it to update like below.

@(Html.Kendo().RadioGroupFor(model => model.Sex)
                .Name("Sex1")
                .HtmlAttributes(new { style = "width:200px;", @class = "RequiredField" })
                .Layout(RadioGroupLayout.Horizontal)
                .Items(m =>
                {
                    m.Add().Label("Male").Value("Male");
                    m.Add().Label("Female").Value("Female");
                    m.Add().Label("N.A.").Value("N.A.");
                })
                .Events(e =>
                {
                    e.Change("Sex_onChange");
                })

)

<script type="text/javascript">

function Sex_onChange(e) {
        var sexList = $("#Sex").data("kendoRadioGroup");
        sexList.trigger("change");
    }

</script>

 

No matter what I tried my model always returns null for the sex when it hits the controller.

 

Below is the model.

 public class ContactViewModel
{
        public Int32 ContactID { get; set; }
        [Required]
        [MaxLength(255)]
        [DisplayName("Display Name:")]
        public String DisplayName { get; set; }
        [Required]
        [MaxLength(10)]
        [DisplayName("Sex:")]
        public string Sex { get; set; }
}
Eyup
Telerik team
 answered on 12 Apr 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?