MVC ---- IEnumerable<T>、List<T> 前台遍历展示
突然做前台数据展示,发现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> 前台遍历展示的更多相关文章
- MVC 从后台页面 取前台页面传递过来的值的几种取法
MVC 从后台页面 取前台页面传递过来的值的几种取法 <1>前台页面 Index视图 注意:用户名表单的name值为txtName 密码表单的name值为txtPassword & ...
- jquery之遍历展示title
//遍历展示title {field:'couponsList',title:'优惠劵类型',width:250,align:'center',sortable:true, formatter:fun ...
- bug解决思路——插入数据时,前台不展示数据
积攒一下平时解决bug时的思路,以后若是一头乱麻时翻出来看看~ 一个bug五一之前就和现场在定位,直到今天才算是定位到问题. 所有bug,还是得重现出来才可以发现问题.现场说登记记录时数据没在前台展示 ...
- springboot+thymeleaf中前台页面展示中、将不同的数字替换成不同的字符串。使用条件运算符
主要用到的知识就是thyme leaf中的条件运算符 表达式:(condition)?:then:else 当条件condition成立时返回then.否则返回else 具体代码:<td th: ...
- MVC 后台DataTable 前台遍历
/// <summary> /// 多级审批流展示 /// </summary> /// <returns></returns> public Acti ...
- Asp.Net MVC WebAPI的创建与前台Jquery ajax后台HttpClient调用详解
1.什么是WebApi,它有什么用途? Web API是一个比较宽泛的概念.这里我们提到Web API特指ASP.NET MVC Web API.在新出的MVC中,增加了WebAPI,用于提供REST ...
- 在ASP.NET MVC中使用Boostrap实现产品的展示、查询、排序、分页
在产品展示中,通常涉及产品的展示方式.查询.排序.分页,本篇就在ASP.NET MVC下,使用Boostrap来实现. 源码放在了GitHub: https://github.com/darrenji ...
- c# table 怎么在前台循环展示 ViewBag
后台 public ActionResult DoctorEvaluation()//前台页面 { HE_Department HE_dt = new HE_Department(); DataTab ...
- .Net MVC生成二维码并前端展示
简介: 二维码又称二维条码,常见的二维码为QR Code,QR全称Quick Response,是一个近几年来移动设备上超流行的一种编码方式,它比传统的Bar Code条形码能存更多的信息,也能表示更 ...
随机推荐
- layer,一个可以让你想到即可做到的javascript弹窗(层)解决方案
学习网址:http://layer.layui.com/ 下载地址:http://res.layui.com/download/layer-v2.1.zip 我们提到的基础参数主要指调用方法时用到的配 ...
- 配置tomcat通过客户端访问
1:在tomcat conf/tomcat-users.xml 文件里 配置用户名和密码,以及访问方式 For example, to add the manager-gui role to ...
- 使用 Mirantis Fuel9.0 部署 OpenStack M
Mirantis Fuel 9 可以实现部署OpenStack M版本web化,管理员只需简单规划就能部署复杂的openstack 组件 安装Fuel9.0 下载官方IOS镜像 https://www ...
- c#null值加法运算
加号都是一个含义啊,操作数不同,加号重载的方法就不一样,当加号的左边或右边含有字符串的时候,总是返回一个不为空的字符串.当加号左右两边都是数值的时候,就会对其进行数学运算,null+任何数都为null ...
- 利用arcgis处理遥感栅格数据,得到省平均值数据
1.准备全国省级行政区数据,需要有省级行政区信息,如下所示: 2.生成渔网数据,操作完成会生成一个面数据和一个点数据,我们主要用点数据进行后面的操作. 3.提取栅格数据的值到渔网点数据中. 4.将区域 ...
- Ubuntu系统下查看显卡相关信息
查看显卡信息 root@ubuntu:/home/ubuntu# lspci |grep -i vga 02:00.0 VGA compatible controller: NVIDIA Corpor ...
- MySQL数据库----存储过程
存储过程 存储过程包含了一系列可执行的sql语句,存储过程存放于MySQL中,通过调用它的名字可以执行其内部的一堆sql -- 存储过程的优点: -- 1.程序与数据实现解耦 -- 2.减少网络传输的 ...
- Putty Technical Note
转载自:http://libai.math.ncu.edu.tw/bcc16/6/putty/puttyt.html Terminal panel Terminal 面板可調整 PuTTY 對於模擬終 ...
- 了解微信小程序
了解微信小程序 版权声明:未经博主授权,内容严禁转载分享! 微信小程序官方网址:https://mp.weixin.qq.com/cgi-bin/wx 某大神知乎专栏地址:七月在夏天 https:// ...
- JavaScript 实现全选 / 反选功能
JavaScript 实现全选 / 反选功能 版权声明:未经授权,内容严禁转载! 构建主体界面 编写 HTML 代码 和 CSS 代码,设计主题界面 <style> #user { wid ...