突然做前台数据展示,发现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. abap 基本知识

    sap gui 安装教程:http://www.itpub.net/forum.php?mod=viewthread&tid=2090890 1:abap 基本数据类型: i(整型),f(浮点 ...

  2. [vue]vue条件渲染v-if(template)和自定义指令directives

    条件渲染: v-if/template <div id="app"> <h1>v-show: display: none</h1> <di ...

  3. java的redis工具类

    package com.mracale.sell.utils; /** * @Auther: Mracale */ import org.springframework.beans.factory.a ...

  4. (转)Elasticsearch分析聚合

    Elasticsearch不仅仅适合做全文检索,分析聚合功能也很好用.下面通过实例来学习. 一.准备数据 {"index":{ "_index": " ...

  5. Java中将xml文件转化为json的两种方式

    原文地址https://blog.csdn.net/a532672728/article/details/76312475 最近有个需求,要将xml转json之后存储在redis中,找来找去发现整体来 ...

  6. 《Enhanced LSTM for Natural Language Inference》(自然语言推理)

    解决的问题 自然语言推理,判断a是否可以推理出b.简单讲就是判断2个句子ab是否有相同的含义. 方法 我们的自然语言推理网络由以下部分组成:输入编码(Input Encoding ),局部推理模型(L ...

  7. uva11354 LCA+最小生成树+dp

    源自大白书 题意 有n座城市通过m条双向道路相连,每条道路都有一个危险系数.你的任务是回答若干个询问,每个询问包含一个起点s和一个终点t,要求找到一条从s到t的路,使得途径所有的边的大最大危险系数最小 ...

  8. EditPlus 4.3.2555 中文版已经发布

    新的版本修复了之前版本出现的多行文本缩进调整的问题. 下载连接在页面左上角!

  9. Azkaban 入门

    需求 实际当中经常有这些场景:每天有一个大任务,这个大任务可以分成A,B,C,D四个小任务,A,B任务之间没有依赖关系,C任务依赖A,B任务的结 果,D任务依赖C任务的结果.一般的做法是,开两个终端同 ...

  10. 修改MySQL数据库中表和表中字段的编码方式的方法

    今天向MySQL数据库中的一张表添加含有中文的数据,可是老是出异常,检查程序并没有发现错误,无奈呀,后来重新检查这张表发现表的编码方式为latin1并且原想可以插入中文的字段的编码方式也是latin1 ...