asp.net mvc - mvc binding for editing multiple items ValidationMessageFor showing for all records -


seems question similar mvc model binding edit list not working issue having returned list nothing. tried follow http://www.c-sharpcorner.com/uploadfile/4b0136/editing-multiple-records-using-model-binding-in-mvc/ converting vb.net

function editall() actionresult     return view(db.recipients.where(function(r) r.type = "email").tolist()) end function  <httppost()> public function editall(recipients list(of recipient)) actionresult     'recipients nothing why???     each item recipient in recipients         dim existing_recip recipient = db.recipients.find(item.id)          existing_recip.emailaddress = item.emailaddress         existing_recip.active = item.active      next      db.savechanges()      return view(recipients)  end function 

and view:

@modeltype list(of concurbridge.models.concur.recipient) @code     viewdata("title") = "editall"     layout = "~/views/shared/_layout.vbhtml" end code  <h2>edit recipients</h2>  @using (html.beginform("editall", "recipients", formmethod.post))     @<table class="table">     @for integer = 0 model.count - 1         @<tr>             <td>                 @html.hidden("recipient.index", i)                 @html.textbox("recipient[" + i.tostring + "].id",                     model(i).id, new {.readonly = "readonly"})             </td>             <td>                 @html.textbox("recipient[" + i.tostring + "].emailaddress",                     model(i).emailaddress)             </td>             <td>                 @html.checkbox("recipient[" + i.tostring + "].active",                     model(i).active)             </td>         </tr>     next         <tr>             <td colspan="3">                 <input type="submit" value="submit" />             </td>         </tr>     </table> end using 

model:

<table("multiusetable")> public class recipient     public property id integer     public property type string     <datatype(datatype.emailaddress),     column("value"),     displayname("email address"),     required(allowemptystrings:=false, errormessage:="email address required")>     public property emailaddress string     public property active boolean end class 


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -