-1

i'm very new to MVC and I want to know if this is possible. I want the JobID to be set to a value that i have in the ViewBag. I want to remove the DropdownList so that the value is automatically assigned without having the user to select the value from the List. Create Task Controller

Create Task View

Website View

If you look at image 3. I want to remove this dropdownlist and have that value already assigned. Any help will be appreciated thank you.

Kiran Joshi
  • 1,758
  • 2
  • 11
  • 34
Liam Botha
  • 19
  • 3

1 Answers1

-1

Disable the dropdownlist for user as below,

Html.DropDownList("JobID", Model.JobID, new {@class = "form-control", @disabled = "disabled" })
shivanju0801
  • 131
  • 2
  • 14
  • Thank you for the reply. Do you know how to set the JobID = to the viewbag.Job? – Liam Botha Oct 20 '18 at 09:35
  • I guess following link can help you with that, [link](https://stackoverflow.com/questions/6807256/dropdownlist-set-selected-value-in-mvc3-razor) – shivanju0801 Oct 20 '18 at 09:48