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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -