My view model looks like :
public class ShippingInfo
{
public string DiagID { get; set; }
public Collection<AddressInfo> AddressSuggestions { get; set; }
}
public class AddressInfo
{
public int ID { get; set; }
public string CompleteAddressInfo { get; set; }
}
When I am trying to bind the radio button in my view, its not rendering.
@if (Model.AddressSuggestions != null)
{
for (int i = 0; i < Model.AddressSuggestions.Count; i++)
{
Html.RadioButtonFor(m => m.AddressSuggestions[i].CompleteAddressInfo, Model.AddressSuggestions[i].CompleteAddressInfo, false);
}
}
I am expecting my radio button selection should persist in the Model when I am posting the form (Model Binding). I would appreciate if anyone points out the problem in my code.
No comments:
Post a Comment