Tahrirlash: Roʻyxatni oʻz ichiga olgan yagona koʻrinish modeli obʼyektini shaklga bogʻlashga harakat qilaman, shunda post bir xil koʻrinish modeli obyektiga qaytadi.
MVC 2 da buni samarali bajaradigan kod bormi?
EditorFor( m => m, "Students", "Students[n]") // wrong but sorta close
// the third parameter specifies the ID of the html control
// ideally, the "Students[n]" could be a prefix for the inner fields
html chiqishi qaerda bo'ladi:
<input id="Students[0]_Name" type="text" value="" />
<input id="Students[1]_Name" type="text" value="" />
<input id="Students[2]_Name" type="text" value="" />
va id yig'ilishi qisman "sinf" ko'rinishida bo'lishi mumkinmi (UI andozasi)?
...
Endi men bu haqda o'ylab ko'rsam, bu nom bilan barcha maydonlarni prefiks qiladimi, deb o'ylayman:
<% foreach( Student student in Model) { %><%
EditorFor( m => student, "Student",
"Students[" + Model.IndexOf(student) + "]" ) %><%
} %>
G'alati... Bu uchinchi parametr qatorini (masalan, "StuffHere") Students va Name orasiga qo'yadi:
id="Students_StuffHere_Name" name="Students.StuffHere.Name"