Oct 23, 2014, 4:12 PM
[CLOSED] Submit form in the model has a list of objects.
Hello good.
I have a problem when doing a submit form in the model has a list of objects.
model
What am I doing wrong ??
As I can fix ??
Thank you very much and greetings !!
I have a problem when doing a submit form in the model has a list of objects.
model
[Model(Name = "ReviewAll")]
public class ReviewAll
{
[ModelField(IDProperty = true, UseNull = true)]
[Field(Ignore = true)]
public int? ReviewID
{
get;
set;
}
[PresenceValidation]
public string Registration
{
get;
set;
}
public List<Wheel> Whell
{
get;
set;
}
}
[Model(Name = "Wheel")]
public class Wheel
{
[ModelField(IDProperty = true, UseNull = true)]
[Field(Ignore = true)]
public int? WheelID
{
get;
set;
}
[PresenceValidation]
public int ReviewID
{
get;
set;
}
public int Axis
{
get;
set;
}
public int Index
{
get;
set;
}
}
controller
public ActionResult RenderView()
{
try
{
ReviewAll ra = new ReviewAll();
List<Wheel> w = new List<Wheel>();
for (int i = 0; i <= 3; i++)
{
Wheel one = new Wheel();
one.Axis = i;
one.Index = i;
w.Add(one);
}
ra.Registration = "test";
ra.Whell = w;
return View(ra);
}
catch
{
}
}
public ActionResult SuccessSubmit(ReviewAll person)
{
X.Msg.Alert("Submit", JSON.Serialize(person)).Show();
return this.FormPanel(true);
}
view
@model Euromaster.Models.ReviewAll
/*
...
*/
X.NumberFieldFor<int>(m => m.Whell[0].Axis).FieldLabel("Axis")
X.NumberFieldFor<int>(m => m.Whell[1].Axis).FieldLabel("Axis")
X.NumberFieldFor<int>(m => m.Whell[2].Axis).FieldLabel("Axis")
When I do submit, Whell this to nullWhat am I doing wrong ??
As I can fix ??
Thank you very much and greetings !!
Last edited by Daniil; Oct 31, 2014 at 11:31 AM.
Reason: [CLOSED]