Dropdown binding problem - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Dropdown binding problem

ashokkumarkpmashokkumarkpm Posts: 1Member
hi friends,
Firstly happy New year...

I have been hiiting my head towards this prob for the past 2 hrs ..
My issue is i am trying to display my dropdownlist in my views (MVC Framework)
my viewmodel class contains the following:

public class two
List items = new List();
public List getItemsnew()
items.Add(new SelectListItem
Text = "one",
Value = "1"
items.Add(new SelectListItem
Text = "two",
Value = "2"
return items;
In my Controller i have the following

two two2 = new two();
List items1 = two2.getItemsnew();
SelectList newselectlist = new SelectList(items1);
ViewData["List1"] = newselectlist;

Error here is while running my application
my dropdown gets displayed but not with the specified values insted

I binds "System.Web.Mvc.SelectListItem " in my dropdown!
for both the values...
I even tried to save the Application..
It saves "System.Web.Mvc.SelectListItem " in mt Database...
I know its jus a minor error some where..
plz guide me..
thanks in Adv
Sign In or Register to comment.