从MVC4中的viewbag列表中显示列表视图(Show listview from viewbag's list in MVC4)

我在控制器的viewbag中列出如下列表:

List<TEAMS_PP.Entity.account> list = new TeacherEval().AllTechersList(); ViewBag.allteacherlist = list;

我确保列表确实出现在ViewBag.allteacherlist中。

我想在视图页面(cshtml)的listview中显示它

我做了以下代码:

@(Html.Kendo().ListView<ViewBag.allteacherlist>() .Name("ListView") .TagName("div") .ClientTemplateId("template") .DataSource(dataSource => dataSource .Read(read => read.Action("Products_Read", "Home")) // Specify the action method and controller name ) .Pageable() )

但是我无法在这里访问viewbag.allteacherlist。

我只想在页面上的viewbag中显示列表。

我能做什么???

请帮帮我。

I have taken list in viewbag in controller as follows:

List<TEAMS_PP.Entity.account> list = new TeacherEval().AllTechersList(); ViewBag.allteacherlist = list;

I have made sure that list do come in ViewBag.allteacherlist.

I wanted to show it in listview on view page(cshtml)

I made following code:

@(Html.Kendo().ListView<ViewBag.allteacherlist>() .Name("ListView") .TagName("div") .ClientTemplateId("template") .DataSource(dataSource => dataSource .Read(read => read.Action("Products_Read", "Home")) // Specify the action method and controller name ) .Pageable() )

But i am not able to access viewbag.allteacherlist over here.

I just want to display list comming in viewbag on the page.

What can i do???

Please help me.

最满意答案

这是正确的语法

@(Html.Kendo().ListView<TEAMS_PP.Entity.account>(ViewBag.allteacherlist as IEnumerable<TEAMS_PP.Entity.account>) .Name("ListView") .TagName("div") .ClientTemplateId("template") .DataSource(dataSource => dataSource .Read(read => read.Action("Products_Read", "Home")) // Specify the action method and controller name ) .Pageable() )

This is the correct syntax

@(Html.Kendo().ListView<TEAMS_PP.Entity.account>(ViewBag.allteacherlist as IEnumerable<TEAMS_PP.Entity.account>) .Name("ListView") .TagName("div") .ClientTemplateId("template") .DataSource(dataSource => dataSource .Read(read => read.Action("Products_Read", "Home")) // Specify the action method and controller name ) .Pageable() )从MVC4中的viewbag列表中显示列表视图(Show listview from viewbag's list in MVC4)

我在控制器的viewbag中列出如下列表:

List<TEAMS_PP.Entity.account> list = new TeacherEval().AllTechersList(); ViewBag.allteacherlist = list;

我确保列表确实出现在ViewBag.allteacherlist中。

我想在视图页面(cshtml)的listview中显示它

我做了以下代码:

@(Html.Kendo().ListView<ViewBag.allteacherlist>() .Name("ListView") .TagName("div") .ClientTemplateId("template") .DataSource(dataSource => dataSource .Read(read => read.Action("Products_Read", "Home")) // Specify the action method and controller name ) .Pageable() )

但是我无法在这里访问viewbag.allteacherlist。

我只想在页面上的viewbag中显示列表。

我能做什么???

请帮帮我。

I have taken list in viewbag in controller as follows:

List<TEAMS_PP.Entity.account> list = new TeacherEval().AllTechersList(); ViewBag.allteacherlist = list;

I have made sure that list do come in ViewBag.allteacherlist.

I wanted to show it in listview on view page(cshtml)

I made following code:

@(Html.Kendo().ListView<ViewBag.allteacherlist>() .Name("ListView") .TagName("div") .ClientTemplateId("template") .DataSource(dataSource => dataSource .Read(read => read.Action("Products_Read", "Home")) // Specify the action method and controller name ) .Pageable() )

But i am not able to access viewbag.allteacherlist over here.

I just want to display list comming in viewbag on the page.

What can i do???

Please help me.

最满意答案

这是正确的语法

@(Html.Kendo().ListView<TEAMS_PP.Entity.account>(ViewBag.allteacherlist as IEnumerable<TEAMS_PP.Entity.account>) .Name("ListView") .TagName("div") .ClientTemplateId("template") .DataSource(dataSource => dataSource .Read(read => read.Action("Products_Read", "Home")) // Specify the action method and controller name ) .Pageable() )

This is the correct syntax

@(Html.Kendo().ListView<TEAMS_PP.Entity.account>(ViewBag.allteacherlist as IEnumerable<TEAMS_PP.Entity.account>) .Name("ListView") .TagName("div") .ClientTemplateId("template") .DataSource(dataSource => dataSource .Read(read => read.Action("Products_Read", "Home")) // Specify the action method and controller name ) .Pageable() )