Click here to Skip to main content
15,888,129 members
Home / Discussions / ASP.NET
   

ASP.NET

 
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 
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 
Looking at the documentation of the DisplayNameFor method[^], there are two overloads:
  • DisplayNameFor(HtmlHelper<TModel>, Expression<Func<TModel, TValue>>)
  • DisplayNameFor(HtmlHelper<IEnumerable<TModel>>, Expression<Func<TModel, TValue>>)

In this case, since your model is IEnumerable<RestaurantReview>, you're calling the second overload.

That overload takes a function which accepts a single item from your enumerable sequence, and returns one of its properties.

So in the code you've posted, model refers to a single RestaurantReview instance, not the IEnumerable<RestaurantReview> represented by the Model.

The naming convention is slightly confusing - it might have made more sense to have:
C#
Html.DisplayNameFor(item => item.Name)




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


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 
AnswerRe: VSflexgrid control in asp.net mvc Pin
jkirkerx16-Sep-15 11:05
professionaljkirkerx16-Sep-15 11:05 
GeneralRe: VSflexgrid control in asp.net mvc Pin
Shaikh Ansar16-Sep-15 20:01
Shaikh Ansar16-Sep-15 20:01 
GeneralRe: VSflexgrid control in asp.net mvc Pin
jkirkerx17-Sep-15 6:23
professionaljkirkerx17-Sep-15 6:23 
GeneralRe: VSflexgrid control in asp.net mvc Pin
Shaikh Ansar17-Sep-15 18:03
Shaikh Ansar17-Sep-15 18:03 
QuestionAsp.net session Pin
Member 1198569615-Sep-15 2:37
Member 1198569615-Sep-15 2:37 
AnswerRe: Asp.net session Pin
jkirkerx16-Sep-15 11:02
professionaljkirkerx16-Sep-15 11:02 
QuestionASP.NET Pin
scud1014-Sep-15 23:35
scud1014-Sep-15 23:35 
AnswerRe: ASP.NET Pin
Richard MacCutchan14-Sep-15 23:53
mveRichard MacCutchan14-Sep-15 23:53 
AnswerRe: ASP.NET Pin
PANKAJMAURYA12-Oct-15 23:17
professionalPANKAJMAURYA12-Oct-15 23:17 
Questionmvc viewbag Pin
Analice14-Sep-15 21:46
Analice14-Sep-15 21:46 

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.