In my ViewModel, I'm passing an IEnumerable property loaded with a list of values for a drop-down box on the web page:
// Drop-down list values...
public IEnumerable< PAYMENT_METHODS > PaymentMethods { get; set; }
And I'm consuming them on the MVC view as follows:
@Html.DropDownListFor(x => Model.objConsultant.Profile.CDE_PAYMENT_METHOD, new SelectList(Model.PaymentMethods, "CDE_PAYMENT_METHOD", "TXT_PAYMENT_METHOD_DESCRIPTION"), htmlAttributes: new { id = "ddlbPaymentMethod" })
I have several buttons on the web page that perform post-back actions as the user works with the web page. The problem is that after the post-back, the PaymentMethods property is null, and thus throws an exception when the page loads. In order to work around this, I had to save the PaymentMethods data on a Session variable during the original GET Index action, and then restore the PaymentMethods property from the Session upon the POST Index action. Am I missing something? Why isn't it saving the IEnumerable data across post actions?