突然做前台数据展示,发现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. 使用SolrJ代码导入,发布搜索服务

    搭建solr服务器:http://www.cnblogs.com/liyafei/p/8005571.html 一导入要搜索的字段 1:确定发布搜索的字段,sql语句 SELECT a.id, b.  ...

  2. (转)Mysql 多表查询详解

    MySQL 多表查询详解 一.前言  二.示例 三.注意事项 一.前言  上篇讲到mysql中关键字执行的顺序,只涉及了一张表:实际应用大部分情况下,查询语句都会涉及到多张表格 : 1.1 多表连接有 ...

  3. mysql 开启慢查询

    linux启用MySQL慢查询 vim /etc/my.cnf [mysqld] slow-query-log = on slow_query_log_file = /var/log/slow_que ...

  4. 你应该知道的最好Webmail邮件客户端,

    1 . Kite Kite is an opensource replacement to Gmail. Kite is a webmail designed to look a lot like g ...

  5. logistics回归

    logistic回归的基本思想 logistic回归是一种分类方法,用于两分类问题.其基本思想为: a. 寻找合适的假设函数,即分类函数,用以预测输入数据的判断结果: b. 构造代价函数,即损失函数, ...

  6. phper

    0 坚持写博客,有独立的博客1 有自己的github项目,目前致力于瓦力:meolu/walle-web · GitHub,瓦尔登:meolu/walden · GitHub变得更实用,欢迎标星:)2 ...

  7. Problem B. Full Binary Tree

    题目 链接:http://code.google.com/codejam/contest/2984486/dashboard#s=p1 googlde code jam 2014 Round1A 解题 ...

  8. mysql在windows下命令行启动与关闭服务

    一.命令行关闭与启动服务的命令: 二.运行cmd的命令行程序时,必须以管理员身份运行.否则会出现如下提示: 三.mysql5.7版本的服务名一般默认为mysql57,因此如果使用服务名mysql,那么 ...

  9. Yosemite安装libv8和therubyracer

    yosemite ruby version升级的时候,会碰到类似 Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before b ...

  10. 生产者消费者模型——wait/notify/notifyAll使用

    告警系统架构如下 1. 数据处理系统处理完原始数据并入库后,发送消息到kafka系统: 2. 告警生产者从kafka系统查询消息存入告警消息队列: 3. 告警消费者从告警消息队列查询消息进行处理. 这 ...