Multiple drop-down list values ​​are sent to the controller.

enter image description here

I need to create a dynamic user interface of this type with drop-down boxes. Drop-down box values ​​are fixed as shown above.

My question is: I need to send the values ​​of the dropdown list of payment types to the mvc controller. I need to send the value of the selected falling to the service key. I do not know how to do that. Any idea?

UPDATE

Payment types can be as transfers. It looks below.

public enum PaymentOption
    {
        [Display(Name = "Select Payment Type")]
        None = 1,

        [Display(Name = "Service Hourly")]
        ServiceHourly = 2,

        [Display(Name = "Salary Flat Rate")]
        SalaryFlatRate = 3,

        [Display(Name = "% of Appointment")]
        PercentOfAppointment = 4,

        [Display(Name = "Per Appointment")]
        PerAppointment = 5,

    }
+5
source share
2 answers

try this code code code

var url = '@Url.Action("Youractionname")';

        $.ajax({
            type: "POST",
            url: url,
            data: '{ddl1: "' + ddl1value+ '",ddl2: "' + ddl2value+ '"}',
            contentType: "application/json; charset=utf-8",
            dataType: "json"
        });


    [HttpPost]
    public ActionResult Youractionname(int ddl1, int ddl2)
    {
        //do work
    }
+1
source

You need to create a list for the “services” and bind the list items to your model.

public class Service {
  string Name { get;set;}
  int PaymentType { get;set;}
  float HourlyRate { get;set;}
}

public class MyModel { 
  ICollection<Service> services { get;set;}
  [...]
}

, :

http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx

+1

All Articles