Mvc4 List şeklindeki modelleri bind etme ( Non-sequental indices model a list bind )

Merhaba arkadaşlar mvc4 ile uğraşan arkadaşlar bilirler, muhakkak ki bir list şeklinde modeli bind etme ihtiyacı duyarlar. 

<input type="text" name="people[0].FirstName" value="George" />
<input type="text" name="people[0].LastName" value="Washington" />
<input type="text" name="people[1].FirstName" value="Abraham" />
<input type="text" name="people[1].LastName" value="Lincoln" />
<input type="text" name="people[3].FirstName" value="Thomas" />
<input type="text" name="people[3].LastName" value="Jefferson" />


Burada people dizi şeklinde yani 0 dan başlamalı ve kesintisiz olmalıdır. Eğer client tarafında bu dizi bozulursa, 0 dan başlamazsa veya kesintiye uğrarsa bind yapamayız.
Ben bu sırazsız dizileri aşağıdaki gibi kulanarak çalışır düzeye getirdim.
İkinci bir çözüm buradaki nuget paketini yüklemektir. Başka bir ipucunda görüşmek üzere hoşçakalın..

     
 @model Core.Image 
@{
 Guid deger = Guid.NewGuid();
}
<li class="span2" data-deger="@deger">
    <input type="hidden" name="images.Index" value="@deger" />
    <input type="hidden" name="images[@(deger)].ImageId"  value="@Model.ImageId"/>
    <input type="hidden" name="images[@(deger)].ProductId"  value="@Model.ProductId"/>
    <input type="hidden" name="images[@(deger)].ImagePath" value="@Model.ImagePath" />

x

x

x

 

Add comment

The file '/Custom/Widgets/Calendar/widget.cshtml' does not exist.The file '/Custom/Widgets/Category list/widget.cshtml' does not exist.The file '/Custom/Widgets/Tag cloud/widget.cshtml' does not exist.The file '/Custom/Widgets/Page List/widget.cshtml' does not exist.The file '/Custom/Widgets/Month List/widget.cshtml' does not exist.