How to make dropdownlist show a selected value in asp.net mvc?
        Posted  
        
            by Pandiya Chendur
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Pandiya Chendur
        
        
        
        Published on 2010-05-04T04:38:38Z
        Indexed on 
            2010/05/04
            5:08 UTC
        
        
        Read the original article
        Hit count: 265
        
I have an edit page with a Html.DropDownList in it....I cant show the dropdownlist value it always shows up with Select instead i want to make the dropdown show an item as selected based on a model value say Model.Mes_Id... Any suggestion how it can be done...
       <p>
            <label for="MeasurementTypeId">MeasurementType:</label>
         <%= Html.DropDownList("MeasurementType", // what should i give here?)%>
            <%= Html.ValidationMessage("MeasurementTypeId", "*") %>
        </p>
EDIT: It has the list items but i want to show a value selected in the edit view...
   public ActionResult Edit(int id)
    {
        var mesurementTypes = consRepository.FindAllMeasurements();
        ViewData["MeasurementType"] = mesurementTypes;
        var material = consRepository.GetMaterial(id);
        return View("Edit", material);
    }
        © Stack Overflow or respective owner