jeudi 1 septembre 2016

How to put a value in dropdown using records from database

I want to put a value from database because my dropdown already have a value the same as the text so I want a separate or different value from my text. Example code = 1, text = pathologist.

My controller:

    public ActionResult MainHistopathologyForm(string id)
        var patientprofileViewModel = new MDHPIStables();
        patientprofileViewModel.histopathology = db.histopathology.Find(id);
        patientprofileViewModel.roles = db.roles.Find(Session["role"]);
        var PathologistList = new List<string>();

        var PathologistQry = from d in db.pathologist
                       select d.pathologist;

        TempData["pathologistlist"] = new SelectList(PathologistList);

        return View(patientprofileViewModel);


 @Html.Partial("RolesHistopathologyForm", Model.roles, new ViewDataDictionary())

@Html.Partial("Partial_HistopathologyForm", Model.histopathology,
 new ViewDataDictionary())


        ViewBag.concurring1 = TempData["pathologistlist"];
    @Html.DropDownList("concurring1", "Select Pathologist")  

Aucun commentaire:

Enregistrer un commentaire