webform repeater控件
Repeater:
HeaderTemplate - 在加载开始执行一遍
ItemTemplate - 有多少条数据,执行多少遍
FooterTemplate - 在加载最后执行一遍
AlternatingItemTemplate - 交替项模板

- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="lianxi.aspx.cs" Inherits="lianxi" %>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title></title>
- </head>
- <body>
- <form id="form1" runat="server">
- <asp:Repeater ID="Repeater1" runat="server">
- <HeaderTemplate>
- <table style="text-align:center">
- <tr style="color:white;padding:10px;">
- <td>UserName</td>
- <td>PsssWord</td>
- <td>NickName</td>
- <td>Sex</td>
- <td>Birthday</td>
- <td>Nation</td>
- </tr>
- </HeaderTemplate>
- <ItemTemplate>
- <tr style=" line-height: 1.5 !important;">">
- <td><%#Eval("UserName")%></td>
- <td><%#Eval("PassWord")%></td>
- <td><%#Eval("NickName")%></td>
- <td><%#Eval("Sex")%></td>
- <td><%#Eval("birthday")%></td>
- <td><%#Eval("Nation")%></td>
- </tr>
- </ItemTemplate>
- <FooterTemplate>
- </table>
- </FooterTemplate>
- </asp:Repeater>
- </form>
- </body>
- </html>


- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- Repeater1.DataSource = new UsersDA().Select();
- Repeater1.DataBind();
- }
- }

库存预警:
通过某个属性值判断后,将某条数据的样式进行更改
属性扩展的方式,写一个返回string类型的属性,返回的是CSS样式表样式

- /// <summary>
- /// 性别
- /// </summary>
- public bool Sex
- {
- get { return _Sex; }
- set { _Sex = value; }
- }
- public string SexStr
- {
- get { return _Sex ? "男" : "女"; }
- }
- private DateTime _Birthday;
- /// <summary>
- /// 生日
- /// </summary>
- public DateTime Birthday
- {
- get { return _Birthday; }
- set { _Birthday = value; }
- }
- public string BirthdayStr
- {
- get { return _Birthday.ToString("yyyy年MM月dd日"); }
- }
- private string _Nation;
- /// <summary>
- /// 民族
- /// </summary>
- public string Nation
- {
- get { return _Nation; }
- set { _Nation = value; }
- }
- public string NationName
- {
- get { return new NationData().Select(this._Nation).NationName; }
- }
- public string Age
- {
- get { return (DateTime.Now.Year - this._Birthday.Year).ToString(); }
- }
- public string Red
- {
- get
- {
- string end = "";
- if (Convert.ToInt32(Age) >= 16)
- {
- end = "";
- }
- return end;
- }
- }


- <ItemTemplate>
- <tr class="tr_Item" style="<%#Eval("Red")%>">
- <td><%#Eval("UserName") %></td>
- <td><%#Eval("PassWord") %></td>
- <td><%#Eval("NickName") %></td>
- <td><%#Eval("SexStr") %></td>
- <td><%#Eval("BirthdayStr") %></td>
- <td><%#Eval("Age") %></td>
- <td><%#Eval("NationName") %></td>
- </tr>
- </ItemTemplate>

光棒效果
鼠标移入改变颜色

- <style type="text/css">
- #tb1 {
- width: 100%;
- background-color: navy;
- text-align: center;
- }
- #tr_head {
- color: white;
- }
- .tr_Item {
- background-color: white;
- }
- .tr_Item2 {
- background-color: #e0e0e0;
- }
- </style>
- <script type="text/javascript">
- window.onload = function () {
- var items = document.getElementsByClassName("tr_Item");
- var oldColor = "";
- for (var i = 0; i < items.length; i++) {
- items[i].onmouseover = function () {
- oldColor = this.style.backgroundColor;
- this.style.backgroundColor = "yellow";
- };
- items[i].onmouseout = function () {
- this.style.backgroundColor = oldColor;
- };
- }
- };
- </script>
webform repeater控件的更多相关文章
- Webform(Repeater控件)
一.Repeater控件 有五大模板 ItemTemplate :有多少条数据,执行多少遍 AlternatingItemTemplate : 对交替数据项进行格式设置 Se ...
- WebForm(四)——Repeater控件(重要、好用)
Repeater控件,可以用来一次显示一组数据项.比如,可以用它们显示一个数据表中的所有行. Repeater控件完全由模板驱动,提供了最大的灵活性,可以任意设置它的输出格式. ...
- Webform中Repeater控件--绑定嵌入C#代码四种方式
网页里面嵌入C#代码用的是<% %>,嵌入php代码<?php ?> 绑定数据的四种方式: 1.直接绑定 <%#Eval("Code") %> ...
- 【2017-05-18】WebForm的Repeater控件和一些简单控件
一.Repeater控件 1. <%@ %> - 这里面写一些声明和引用的 <% %> - 编写C#代码的 <%= %> - 往界面上输出一个变量的值 <% ...
- 【2017-05-18】WebForm的Repeater控件及简单控件
<%@ %> - 这里面写一些声明和引用的 <% %> - 编写C#代码的 <%= %> - 往界面上输出一个变量的值 <%# Eval("属性名 ...
- webform之Repeater控件
一.Repeater控件 数据循环编辑 1.repeater包括五大模板: (1)HeaderTemplate:标题模板,对开头进行编辑,只执行一次 (2)FooterTemplate:页尾结束模板, ...
- ASP.Net中通过Jquery前端对Repeater控件绑定的数据进行操作
说明:由于Repeater控件是动态绑定,通过Id获取数据只能默认获取第一行: 1.对Repeater中div设置样式 2.通过$(".css").each(function(){ ...
- Repeater 控件
Repeater 控件是一个容器控件,可用于从网页的任何可用数据中创建自定义列表.Repeater 控件没有自己内置的呈现功能,这意味着用户必须通过创建模板来提供 Repeater 控件的布局.当网页 ...
- Repeater控件用法
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Repeater.aspx. ...
随机推荐
- overflow 清除浮动
对overflow的理解还停留在“规定当内容溢出元素框时发生的事情”,这种简单的认识上,今天发现overflow还可以清除浮动. <style> .outside{ height:auto ...
- 【转】精心推荐几款超实用的 CSS 开发工具
原文转自:http://www.html5cn.org/article-5741-1.html 摘要: 当你开发一个网站或 Web 应用程序的时候,有合适的工具,绝对可以帮助您节省大量的时间.在这篇文 ...
- phpstorm 激活
http://idea.lanyus.com/
- 编写更好的jQuery代码的建议(share)
留个备份! 原文链接: Mathew Carella 翻译: 伯乐在线- yanhaijing译文链接: http://blog.jobbole.com/52770/ 讨论jQuery和javas ...
- 初学Html
HTML,超文本标记语言,文本解释性语言,它的源代码不通过编译而直接在浏览器中运行时被翻译,其决定的是网页的结构和内容. 一谈html,自然首先是浏览器,比较具有代表性的浏览器则是谷歌.火狐.IE.苹 ...
- java Scanner
public static void main(String[] args) throws IOException { System.out.print("Enter a number:&q ...
- 034. asp.netWeb用户控件之三通过用户控件实现用户注册和登录
用户控件login.ascx代码: <%@ Control Language="C#" AutoEventWireup="true" CodeFile=& ...
- 数据库之mysql存储程序
什么时候会用到存储过程 1.存储过程只在创造时进行编译,以后每次执行存储过程都不需再重新编译,而一般 SQL 语句每执行一次就编译一次,所以使用存储过程可提高数据库执行速度2.当对数据库进行复杂操作时 ...
- Unity Shader——Writing Surface Shaders(2)——Custom Lighting models in Surface Shaders
Surface Shader中的自定义光照模型 当你在编写 Surface Shaders 时,是在描述一个表面的属性(反射颜色.法线……),而且光的交互过程是由一个光照模型来计算的.内建的光照模型有 ...
- python模块介绍- SocketServer 网络服务框架
来源:https://my.oschina.net/u/1433482/blog/190612 摘要: SocketServer简化了网络服务器的编写.它有4个类:TCPServer,UDPServe ...