Guest User

Guest User

  • Tech Writer
  • 515
  • 46.3k

About dropdown onchange event

Nov 3 2021 2:05 PM

hello,

I am calling javascript function on onchange event of dropdown, The dropdown is inside my grid, so want to pass Id in javascript function. Following is the code :

@Html.DropDownListFor(Model => item.Id, new List<SelectListItem>
                                  {
                                    new SelectListItem() {Text = "No", Value="0"},
                                   new SelectListItem() {Text = "Yes", Value="1",Selected=item.Active}
                                  }, new { id = "ddlStatus",
                                      onchange = "UpdateStatus('@item.Id')"
                                  })

 

but it does get value of item.Id, but if I pass static value in it, it will work 


Answers (8)