asp.net mvc - MVC Pass object through view by view name -


when calling method below, works expected`

 [httpget]         public actionresult edit(int id)         {             viewbag.replylist = new businesslayer.telesales().getallreplies();             //viewbag.assignto = new businesslayer.users().getusersbyrolename("sales rep");              commonlayer.telesales telesale = new businesslayer.telesales().gettelesale(id);             return view(telesale);         } 

however, after updating database below, try recall same view , pass same parameters in previous method. reason when method below calls view, nullreferenceexception error on dropdownlist being populated viewbag

        [httppost]         public actionresult edit(commonlayer.telesales telesale)         {             viewbag.replylist = new businesslayer.telesales().getallreplies();              if (telesale.reply != 1)             {                  new businesslayer.telesales().updatetelesale(telesale,user.identity.name);                 //appointment                 if (telesale.reply == 6)                 {                     viewbag.appointment = true;                     viewbag.replylist = new businesslayer.telesales().getallreplies();                     return view("edit", (object)telesale);                     } } 

the view expects , object @model commonlayer.telesales

system.nullreferenceexception: object reference not set instance of object. on following line inside view:

   line 53:       <div> line 54:             @html.dropdownlistfor(model => model.reply, new selectlist(viewbag.replylist, "id", "reply", model.telesalesreplies.id), new { style = "height:31px;width:312px;" }) line 55:             @html.validationmessagefor(model => model.reply) line 56:         </div> 

what doing wrong?


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -