c# - asp.net mvc 3 model binding dropdown -


i have view form. on form have textboxes , 2 dropdownlists.

this viewmodel.

public class newapplicationviewmodel {     public applicationdata application { get; set; }      //selectlists     public selectlist questionnaires { get; set; }     public selectlist jobs { get; set; } } 

the applicatoindata class looks this

    public class applicationdata {     [hiddeninput(displayvalue = false)]     public guid id { get; set; }     [required]     public applicantdata applicant { get; set; }     [required]     public questionnairedata questionnaire { get; set; }     [required]     public jobdata job { get; set; }     public string pdf { get; set; } } 

the "questionnaire" , te "job" have selected dropdownlists. how can bind selected value in dropdown object in "applicationdata"? complete, controller action hande form submit.

    [httppost]     public actionresult newapplication([bind(prefix="application")]applicationdata model)     {         var application = mapper.map<applicationdata, application>(model);         _applicationrepository.add(application);         _session.commit();         return view();     } 

thanks

@html.dropdownlistfor(     x => x.application.questionnaire.id,     model.questionnaires )  @html.dropdownlistfor(     x => x.application.job.id,     model.jobs ) 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -