asp.net - Can't get value from @Html.RadioButtonFor with complex types -
I have a list of objects, each of which has nested lists, each of which has a date property. There is a need to select one of them.
The model looks like
see public class models [public IList & lt; parentclass & gt; Get pension packages {receive; Set;}} Public Class Pantalaklos {Public ILIT & lt; DateTime & gt; Date Selectors {date} selected the public date time for the selected date {get; Set;}} Public Class Date Manager {Public Date Time {get; Set}}} for the selected action:
@using (Html.BeginForm ()) {for (int i = 0; i & lt ; @model parentclasses.Qount; i ++) {for (int j = 0; j & lt; @ models. Parentclasses [i] .datasilectors.kount; j ++) {@ Html.RadioButtonFor (m = & gt; ; M.ParentClasses [i], Model. ParentClass [i] .Data Solalkers [J] .Det, new {@id = Model. ParentClass [i] .Det Solalklers [J] .Data Torstring ("MMDDI")}) @model Parent Classes [i] .Det Solalklers [J]. date. To shortcode string () & lt; Br / & gt; } & Lt; Button type = "submit" & gt; Submit & lt; / Button & gt; }} The view provides as expected, but I can not find any value for the selected date. HTML renders such as
& lt; Form method = "post" action = "/ date / select date" & gt; & Lt; Input id = "04272014" type = "radio" value = "4/27/2014 12:00:00 am" name = "parent classes [0]" & gt; & Lt; / Input & gt; 4/27/2014 & lt; Br> & Lt; / Br & gt; & Lt; Input ID = "11012014" type = "radio" value = "11/1/2014 12:00:00 am" name = "parent classes [0]" & gt; & Lt; / Input & gt; 11/1/2014 & lt; Br> & Lt; / Br & gt; & Lt; Button type = "submit" & gt; & Lt; / Button & gt; Submit & lt; / Form & gt; I appreciate any insights here, I am already on this project two days ago.
Thanks
It's been a while since using the razor , But I believe that your Initial Lambda is for the property selector on HTML. Radiyubutenfo is wrong. You are trying to bind, instead of ParentClass, you control the value of ParentClass instances. The selected date I believe is that if you change it in:
@ html.RadioButtonFor (m => m.ParentClasses [i]. Selected date, model. ParenClasses [i] .Det Sonnike [J] {@id = Model.PantCLus [i] .Det Sealers [J] .Dt. Towstring ("MMddyyyy")}) This can work for you If it is still not working, please post back and I will see about doing a sample work.
Comments
Post a Comment