I have run into an issue with the DataSource object of my Grid. In short, I bind the current record in the Grid DataSource to a popup window, make some changes to the model in the view (which makes the record "dirty"), and click a save button which calls the myGrid.dataSource.sync() method.
All is well and good up to the point when my Controller receives the POST on the server-side. My model contains a collection property. The problem is that the model being posted by the DataSource is sending the collection property names in the wrong format and ASP.NET does not know how to bind the data to my model.
Here is an example of my model:
Like I mentioned before, everything works as expected, up until the model changes are posted to the server. This is the format the model property names are sent in when received by the server:
This is confusing to me. Why are there brackets around the collection property names? There should be a dot after the index (i.e. Member.Relatives[0].Name). Also, why is the model posted twice and in a more incorrect format?
All is well and good up to the point when my Controller receives the POST on the server-side. My model contains a collection property. The problem is that the model being posted by the DataSource is sending the collection property names in the wrong format and ASP.NET does not know how to bind the data to my model.
Here is an example of my model:
public
class
Member {
public
Member() {
this
.Relatives =
new
List<Relative>();
}
public
string
Id {
get
;
set
; }
public
string
Name {
get
;
set
; }
public
ICollection<Relative> Relatives {
get
;
set
; }
}
public
class
Relative {
public
string
Name {
get
;
set
; }
public
int
Age {
get
;
set
; }
}
Member.Id
Member.Name
Member.Relatives[0][Name]
Member.Relatives[0][Age]
Member.Relatives[1][Name]
Member.Relatives[1][Age]
Member[Id]
Member[Name]
Member[Relatives][0][Name]
Member[Relatives][0][Age]
Member[Relatives][1][Name]
Member[Relatives][1][Age]