ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1727
Number of posts: 3292

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Dropdown binding problem Posted by ashokkumarkpm on 31 Dec 2010 at 7:42 AM
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<SelectListItem> items = new List<SelectListItem>();
public List<SelectListItem> 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<SelectListItem> 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
Ashok.....
Thread Tree
ashokkumarkpm Dropdown binding problem on 31 Dec 2010 at 7:42 AM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.