Hello Friends,
this is my Question extension to this Question..
Here I am able to add the Dropdown list value to the Grid.. perfectly..
Ex: in my Dropdownlist box I have A B C D items..
When I add any Item I am displaying the grid and I am reloading my page.
My grid have two columns one is added Dropdownlist value.. other is some other text value..
each row in my grid have Edit button..
When I click Edit I am reloading my page to edit this selected dropdownlist value..
when I click Edit I need to show what ever the Dropdownlist value I have in the grid I need to show in the Dropdownlist..
so that user knows he has this dropdown value..
please let me know if any body not undrestood my question..
thanks
My Controler code..
public ActionResult Edit(int? id)
{
if (id.HasValue)
{
// _viewModel.ObnCategoryTextComponent = _obnRepository.GetObnCategoryById(id.Value);
var data = _obnRepository.GetSingle<ObnCategory>(id.Value);
string selectedValue = data.ObnCategoryName;
_viewModel.ServiceTypeListAll = new SelectList(_bvRepository.GetAllServiceTypes().OrderBy(n => n.ServiceTypeName), "ServiceTypeName", "ServiceTypeName", selectedValue);
// _viewModel.Category = data.ObnCategoryName;
}
return PartialView("Index",_viewModel);
}
My View is..
<%=Html.DropDownList("ServiceTypeListAll",Model.ServiceTypeListAll)%>