突然做前台数据展示,发现IEnumerable 对一个列表的展示还是可以,但要是多个类型放在一个表中如何处理呢,如下:

一个类IEnumerable遍历

后台

 public IEnumerable<NewsEntity> GetNotice()
{
int type = ;
return noticeBLL.GetListByType(type);
}

前台:

引用
@model IEnumerable<LeaRun.Application.Entity.PublicInfoManage.NewsEntity>
<div class="panel-body">
<ul>
@foreach (var item in Model)
{
<li><a href="#">@item.FullHead</a><span class="time">@item.CreateDate.ToString().Split(' ')[].Replace("/", "-")</span></li>
}
</ul>
</div>

多个类型放在同一个表中处理方式

    首先在control中建一个临时类

   /// <summary>
/// 公告实体封装
/// </summary>
public class GetIEnumerable
{
/// <summary>
/// 公告
/// </summary>
public IEnumerable<NewsEntity> Notice { get; set; }
/// <summary>
/// 新闻
/// </summary>
public IEnumerable<NewsEntity> News { get; set; }
}

用法:

    public GetIEnumerable GetNotice()
{
GetIEnumerable ge = new GetIEnumerable();
int type = ;//2、公告
ge.Notice = noticeBLL.GetListByType(type); type = ; //1、新闻
ge.News = noticeBLL.GetListByType(type);
return ge;
}     //网页面上跳转
   public ActionResult AdminLTEDesktop()
{
return View(GetNotice());
}

页面:

引用
@model LeaRun.Application.Web.Controllers.GetIEnumerable
<div class="panel-body">
  <ul>
@foreach (var item in Model.News)
{
<li><a href="#">@item.FullHead</a><span class="time">@item.CreateDate.ToString().Split(' ')[].Replace("/","-")</span></li>
}
</ul>
</div> <div class="panel-body">
<ul>
@foreach (var item in Model.Notice)
{
<li><a href="#">@item.FullHead</a><span class="time">@item.CreateDate.ToString().Split(' ')[].Replace("/", "-")</span></li>
}
</ul>
</div>

======================================================================================================

List<T> 页面遍历

引用命名空间

@using System.Data;
@using NFine.Domain._03_Entity.POCO.Business;
@model List<NFine.Domain._03_Entity.POCO.Business.CustomerAndFollow>
  @{ foreach (CustomerAndFollow activities in Model)
{
<table class="ui-jqgrid-btable ui-common-table table table-bordered" style=" background:#ffffff!important; margin-bottom:30px;">
<tbody>
<tr class="jqgfirstrow">
<td style="height:50px;line-height:50px;">@activities.CustomerId</td>
<td style="height:50px;line-height:50px;">@activities.F_FullName</td>
<td style="height:50px;line-height:50px;">@activities.F_Msisdn</td>
<td style="height:50px;line-height:50px;">@activities.F_CreatorTime</td>
<td style="height:50px;line-height:50px;">@activities.F_CreatorUserName</td>
</tr>
<tr>
<td colspan="">
<textarea id="@activities.FollowId" class="ckeditor">@activities.F_Description</textarea>
</td>
</tr>
</tbody>
</table>
}}

后台:

    public override ActionResult Index()
{
int record = ;
Pagination page = new Pagination();
page.rows = ;
page.page = ;
page.records = record;
List<CustomerAndFollow> follow = custapp.GetFollowList(page, out record);
return View(follow);
}

MVC ---- IEnumerable<T>、List<T> 前台遍历展示的更多相关文章

  1. MVC 从后台页面 取前台页面传递过来的值的几种取法

      MVC 从后台页面 取前台页面传递过来的值的几种取法   <1>前台页面 Index视图 注意:用户名表单的name值为txtName 密码表单的name值为txtPassword & ...

  2. jquery之遍历展示title

    //遍历展示title {field:'couponsList',title:'优惠劵类型',width:250,align:'center',sortable:true, formatter:fun ...

  3. bug解决思路——插入数据时,前台不展示数据

    积攒一下平时解决bug时的思路,以后若是一头乱麻时翻出来看看~ 一个bug五一之前就和现场在定位,直到今天才算是定位到问题. 所有bug,还是得重现出来才可以发现问题.现场说登记记录时数据没在前台展示 ...

  4. springboot+thymeleaf中前台页面展示中、将不同的数字替换成不同的字符串。使用条件运算符

    主要用到的知识就是thyme leaf中的条件运算符 表达式:(condition)?:then:else 当条件condition成立时返回then.否则返回else 具体代码:<td th: ...

  5. MVC 后台DataTable 前台遍历

    /// <summary> /// 多级审批流展示 /// </summary> /// <returns></returns> public Acti ...

  6. Asp.Net MVC WebAPI的创建与前台Jquery ajax后台HttpClient调用详解

    1.什么是WebApi,它有什么用途? Web API是一个比较宽泛的概念.这里我们提到Web API特指ASP.NET MVC Web API.在新出的MVC中,增加了WebAPI,用于提供REST ...

  7. 在ASP.NET MVC中使用Boostrap实现产品的展示、查询、排序、分页

    在产品展示中,通常涉及产品的展示方式.查询.排序.分页,本篇就在ASP.NET MVC下,使用Boostrap来实现. 源码放在了GitHub: https://github.com/darrenji ...

  8. c# table 怎么在前台循环展示 ViewBag

    后台 public ActionResult DoctorEvaluation()//前台页面 { HE_Department HE_dt = new HE_Department(); DataTab ...

  9. .Net MVC生成二维码并前端展示

    简介: 二维码又称二维条码,常见的二维码为QR Code,QR全称Quick Response,是一个近几年来移动设备上超流行的一种编码方式,它比传统的Bar Code条形码能存更多的信息,也能表示更 ...

随机推荐

  1. 下载google play上最新版的apk

    注意,是下载最新版的方法,不是像很多网站下的是旧版本 http://techapple.net/2014/09/3-websites-directly-download-apk-google-play ...

  2. Selenium定位元素-Xpath的使用方法

    工具 Xpath的练习建议下载火狐浏览器,下载插件Firebug.Firepath. 由于最新版火狐不支持Firebug等扩展工具了,所以需要下载49版以下的版本安装https://ftp.mozil ...

  3. spark的ML和MLLib两个包区别和联系?

    原文链接:https://www.zhihu.com/question/35225203/answer/123986969 1. 技术角度上,面向的数据集类型不一样:ML的API是面向Dataset的 ...

  4. WebService之Axis2(2):复合类型数据的传递

    在实际的应用中,不仅需要使用WebService来传递简单类型的数据,有时也需要传递更复杂的数据,这些数据可以被称为复合类型的数据.数组与类(接口)是比较常用的复合类型.在Axis2中可以直接使用将W ...

  5. 验证 Googlebot (检查是否为真的Google机器人)

    您可以验证访问您服务器的网页抓取工具是否确实是 Googlebot(还是其他 Google 用户代理).如果您担心自称是 Googlebot 的垃圾内容发布者或其他麻烦制造者访问您的网站,则会发现该方 ...

  6. react-native 0.57 run-ios 失败解决办法

    React Native 日常报错 'config.h' file not found     版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_ ...

  7. Summary: rand5构造rand7

    给一个方法,比如 rand5(), 它能够等概率生成 1-5 之间的整数. 所谓等概率就是1,2,3,4,5 生产的概率均为 0.2 .现在利用rand5(), 构造一个能够等概率生成 1- 7 的方 ...

  8. JSON草稿

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  9. ajax请求头设置 | header 传token

    $('.w-entry-btn').on('tap',function(){ var urlAddress = '/api/address'; var valToken = JSON.parse(lo ...

  10. schema与catalog的理解

    sql环境中Catalog和Schema都属于抽象概念,主要用来解决命名冲突问题.一个数据库系统包含多个Catalog,每个Catalog包含多个Schema,每个Schema包含多个数据库对象(表. ...