I am new in mvc 4 but getting progress. I'm getting crazy with something which how i can select an item in select list in view model. here is my controller code;
ViewBag.DepartmanListesi = new SelectList(VeriTabani.UnvanDepartmanlaris, "UDepId", "Departman");
and in my view model I am listing a diffirent database but in this list one field includes an id of the UnvanDepartmanlaris
.instead of showing the id, I want to show name of the id. but what I have tried is not worked. can you please help me.
I searched many things but most of them was about how to set dropdownlist. I couldnt find any answer of my question.
Thank you in advance. I will be waiting for any response
I'm using following approach. Hope it helps:
Create helper class (I'm having here all my selectlists)
Than in your View:
Works for me.