Click here to Skip to main content
15,922,407 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Help .aspx/ going to another page Pin
Richard Deeming21-Sep-15 2:39
mveRichard Deeming21-Sep-15 2:39 
QuestionMVC Java Script Help Required Pin
Member 766920320-Sep-15 13:03
Member 766920320-Sep-15 13:03 
AnswerRe: MVC Java Script Help Required Pin
Richard Deeming21-Sep-15 2:30
mveRichard Deeming21-Sep-15 2:30 
QuestionJavaScript with .net Pin
PRAKAS PANDEY19-Sep-15 18:01
PRAKAS PANDEY19-Sep-15 18:01 
AnswerRe: JavaScript with .net Pin
Blikkies21-Sep-15 0:42
professionalBlikkies21-Sep-15 0:42 
AnswerRe: JavaScript with .net Pin
aarif moh shaikh1-Oct-15 0:38
professionalaarif moh shaikh1-Oct-15 0:38 
Questionmodel vs Model Pin
Member 1206160019-Sep-15 11:59
Member 1206160019-Sep-15 11:59 
AnswerRe: model vs Model Pin
Kornfeld Eliyahu Peter19-Sep-15 20:04
professionalKornfeld Eliyahu Peter19-Sep-15 20:04 
GeneralRe: model vs Model Pin
Member 1206160020-Sep-15 0:18
Member 1206160020-Sep-15 0:18 
AnswerRe: model vs Model Pin
Kornfeld Eliyahu Peter20-Sep-15 0:56
professionalKornfeld Eliyahu Peter20-Sep-15 0:56 
GeneralRe: model vs Model Pin
Member 1206160020-Sep-15 1:34
Member 1206160020-Sep-15 1:34 
GeneralRe: model vs Model Pin
Kornfeld Eliyahu Peter20-Sep-15 1:57
professionalKornfeld Eliyahu Peter20-Sep-15 1:57 
GeneralRe: model vs Model Pin
Member 1206160020-Sep-15 2:57
Member 1206160020-Sep-15 2:57 
AnswerRe: model vs Model Pin
Kornfeld Eliyahu Peter20-Sep-15 3:11
professionalKornfeld Eliyahu Peter20-Sep-15 3:11 
GeneralRe: model vs Model Pin
Member 1206160020-Sep-15 3:41
Member 1206160020-Sep-15 3:41 
AnswerRe: model vs Model Pin
F-ES Sitecore20-Sep-15 1:12
professionalF-ES Sitecore20-Sep-15 1:12 
When referring to the model passed to the view you use Model. Your DisplayFor is an extension that works on the current model object and it uses a lambda expression to say what property you are interested in, with the "model => model.Name" being the expression. The way expressions work is you pick a variable that is used to refer to the object, that's the bit before the =>. Anything after the => you can use that variable. The variable can be anything though, the reason model.Name is working for you is because you called the variable model. This code is just as valid

C#
@Html.DisplayNameFor(xyz => xyz.Rating)


In that case xyz is the same type as your model and Rating is the property on your model.

Your code isn't valid though as your model is an IEnumerable which doesn't have properties like name etc. If you want to get the header row for your data, you can do something like

@Html.DisplayNameFor(model => model.First().Name)


"model" is your IEnumerable so you're accessing the Name property of the first item in your IEnumerable which will be a RestaurantReview type. Note this will fail if you don't have any items in your model, so check the model isn't empty first.
GeneralRe: model vs Model Pin
Member 1206160020-Sep-15 1:38
Member 1206160020-Sep-15 1:38 
GeneralRe: model vs Model Pin
Richard Deeming21-Sep-15 2:24
mveRichard Deeming21-Sep-15 2:24 
GeneralRe: model vs Model Pin
Member 1206160021-Sep-15 2:50
Member 1206160021-Sep-15 2:50 
GeneralRe: model vs Model Pin
Member 1206160021-Sep-15 2:56
Member 1206160021-Sep-15 2:56 
GeneralRe: model vs Model Pin
Richard Deeming21-Sep-15 3:19
mveRichard Deeming21-Sep-15 3:19 
GeneralRe: model vs Model Pin
Member 1206160021-Sep-15 4:31
Member 1206160021-Sep-15 4:31 
GeneralRe: model vs Model Pin
Richard Deeming21-Sep-15 6:14
mveRichard Deeming21-Sep-15 6:14 
GeneralRe: model vs Model Pin
Member 1206160021-Sep-15 8:41
Member 1206160021-Sep-15 8:41 
QuestionVSflexgrid control in asp.net mvc Pin
Shaikh Ansar15-Sep-15 19:06
Shaikh Ansar15-Sep-15 19:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.