I've got data filled enumerator which I send to the view, I render the EditorForModel like this:
@model IEnumerable<TestProj.Models.Hours>
@Html.EditorForModel()
than in the EditorTemplates.Hours.cshtml:
@model TestProj.Models.Hours
<div>
@Html.CheckBoxFor(
x => x.Selected,
new {
@class = "jcf-unselectable",
id = HtmlHelper.GenerateIdFromName("cb_slice." + ViewData.TemplateInfo.GetFullHtmlFieldName(""))
}
)
@Html.LabelFor(x => x.SliceName)
</div>
When the page is rendered I want to show all the the SliceNames data , Not the entity's name "SliceName" for the labels display.
So it will render the checkbox along with the label with the data behind SliceName.
I'm trying this option since I've understood using viewbags with loops ain't recommended, However I'd like suggestion behind the EditorForModel scope as well.
EDIT: If I use :
@Html.DisplayTextFor(x => x.SliceName)
-Ill get the data behind SliceName (Text only).
If I Use :
@Html.LabelFor(x => x.SliceName)
-Ill get the title "SliceName" for the label's text.
How do I use @Html.LabelFor to get the data as text like @Html.DisplayTextFor?