[RESOLVED]Model is not taking the dropdownlist values in Edit

HI ,

I am showing the records to be edited in a modal dialog. And its showing properly. But while postinh back to save the edited data model is not taking the ddl values.

Iam populating the ddl as follows from the controller action

  List<string> marketgrouplist = new List<string>();
            marketgrouplist = listmodel.sourceData.Select(x => x.MarketGroup).Distinct().ToList();         
            ViewBag.ListofMarketGroup = new SelectList(marketgrouplist, selectedmg);

And model is

 <div class="form-group">
            @Html.LabelFor(model => model.MarketGroup, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
               @Html.DropDownList( "ListofMarketGroup")

Its displaying correctly the details but when i click the save button it not taking the ddl values in the model.

Pls help me



Try updating code like this:

 @Html.DropDownListFor(m => m.MarketGroup, ViewBag.ListofMarketGroup)

sorry not working..showing no such overloaded method

but with some chnages itsss working…thanks a loooooot

 @Html.DropDownListFor(model => model.MarketGroup,(SelectList) ViewBag.ListofMarketGroup)


Still exist one more problem

I am having a field id in my model, i need to set the value filed of the ddl with that id list like i set the text filed with the marketgroup list.

What changes i need to make for that





Still exist one more problem

Try to ask it in New thread, with proper code posting and with some more details.

Leave a Reply