Skip to content
Loading
Issue with DropDownlist in asp.net core mvc    
  •             //state    
  •             class="row">    
  •                 class="alert-danger" asp-validation-summary="ModelOnly">    
  •                 class="col-xs-12 col-sm-6 col-md-6 col-lg-4">    
  •                     for="statename" class="control-label">    
  •                     for="stateId"    
  •                             class="form-control"    
  •                             asp-items="@(new SelectList(@ViewBag.listofstate,"stateId","statename"))">    
  •                     
  •                 
  •             //city    
  •             class="row">    
  •                 class="alert-danger" asp-validation-summary="ModelOnly">    
  •                 class="col-xs-12 col-sm-6 col-md-6 col-lg-4">    
  •                     for="cityname" class="control-label">    
  •                     for="cityId"    
  •                             class="form-control"    
  •                             asp-items="@(new SelectList(@ViewBag.listofcity,"cityId","cityname"))">    
  •                     
  •               
  • error : value cannot be null and another error:
    1. asp-items="@(new SelectList(@ViewBag.listofcountry,"countryId","countryname"))">  
    2. my debugger can not check code:  
    3. @{  
    4. Layout = null;  
    5. } @*here stop my debugger and give an error value can not be null*@  
    6. @* debugger can not check the below code html *@  
    7.   
    Image:
    Error

    1 Reply

    Know the answer? Post it — somebody with the same question will find it here.