c# - Set Dropdownlist Selected Value in the View -
I have to set a set set using dragdrionist razor, but because it is used multiple times in a single page List, I can not set the selected value in the controller, so how do I see it?
Actual Controller List Code:
ViewBag.CargaTipos = new SelectList (Db.CargaTipos, "Id", "Nome"). Orderbiz (c => c.Text); Actual view:
@ html.DropDownListFor (modelItem = & gt; item.cargoipe.id, (IEnumerable & lt; SelectListItem & gt;) View Bag.CargaTipos) [Code] [Table] (Table ("Caragas")] Public Category Kga {{Key] [Database Generated Feature (Database Generated Opportunity. IDTT)] Public Ent ID {Get; Set;} [Required] ] [External ("cargoipo")] Public will enter Tippo_ID {receive; set;} [display (name = "tipo de carga")] of public virtual Go to tip carpo tip {receipt (set;}} [tab] ("carga typos")] public partial class carpetipo {public carpetipo ()} (this cargace = new hashset & lt; cargo & gt; ();} [key ] [Database GeneratedAutit (Publications), Public Entit ID {Received; Set;} Public String Nom {Received; Set;} Public Virtual Icoding & lt; Taxa & gt; Cargas {Receive; Set;}} << Code>
Selected value code> Selected list category. Use it instead see Bag.Cargatipos = DB Kargatipos; View
@ html.DropDownListFor (modelItem => item.CargaTipo.Id, New SelectList (ViewBag.CargaTipos, "Id", " Nome ", YOUR_SELECTED_VALUE))
Comments
Post a Comment