0

I am new to ASP.NET MVC3!! I want to display a text box for my property which is of list type. I am using Razor view. In that i am using @Html.EditorFor(), but this method is not working if my property is complex like List. Also I want to display a Dropdown in my view.

Can anyone tell the solution for this? Thanks!!!

Jash
  • 942
  • 4
  • 17
  • 40
  • A text box for a list property? You need to decide how you'd like to see the items in there, and then write your own code to display the data – Zruty May 18 '11 at 07:25
  • Sorry for the confusion. What I want is a dropdown which will be populated from my property which is of type List in my model class. – Jash May 18 '11 at 08:06
  • I have tried this. Inner Property does not exist. Can anyone give some other ideas – Jash May 18 '11 at 08:25

2 Answers2

0
@Html.DropDownListFor(x=>x.Property.Select(y=>y.InnerProperty))

will probably get you displaying what you want but you will have trouble model binding

w://

0

I had a similar question to this. Hope it helps you out: DropDown for Edit() [Razor]View, Pre-Loaded with Data from Model

Possibly this one also: Create a Dropdown List for MVC3 using Entity Framework (.edmx Model) & Razor Views && Insert A Database Record to Multiple Tables

Tim

Community
  • 1
  • 1
Timothy Green
  • 1,851
  • 5
  • 17
  • 22