asp.net - ASP .NET MVC CSHTML - DropDownList -
im trying retrieve data localdb in cshtml file this:
@html.labelfor(model => model.tipocliente, "tipo cliente", new { @class = "control-label col-md-2" }) <div class="col-md-10"> @{list<selectlistitem> listitems = new list<selectlistitem>(); foreach (var item in model.tipoclientenamespace.tipoclientevalor) { listitems.add(new selectlistitem { text =(string) item.descricao }); }} @html.dropdownlist("tipo cliente", listitems, new { @class = "form-control" }) @html.validationmessagefor(model => model.tipocliente) </div>
but error "object reference not set instance of object." on line
foreach (var item in model.tipoclientenamespace.tipoclientevalor)
anyone can me?
Comments
Post a Comment