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控件的更多相关文章

  1. Webform(Repeater控件)

    一.Repeater控件 有五大模板 ItemTemplate :有多少条数据,执行多少遍        AlternatingItemTemplate : 对交替数据项进行格式设置       Se ...

  2. WebForm(四)——Repeater控件(重要、好用)

    Repeater控件,可以用来一次显示一组数据项.比如,可以用它们显示一个数据表中的所有行.             Repeater控件完全由模板驱动,提供了最大的灵活性,可以任意设置它的输出格式. ...

  3. Webform中Repeater控件--绑定嵌入C#代码四种方式

    网页里面嵌入C#代码用的是<% %>,嵌入php代码<?php ?> 绑定数据的四种方式: 1.直接绑定 <%#Eval("Code") %> ...

  4. 【2017-05-18】WebForm的Repeater控件和一些简单控件

    一.Repeater控件 1. <%@ %> - 这里面写一些声明和引用的 <%  %> - 编写C#代码的 <%= %> - 往界面上输出一个变量的值 <% ...

  5. 【2017-05-18】WebForm的Repeater控件及简单控件

    <%@ %> - 这里面写一些声明和引用的 <%  %> - 编写C#代码的 <%= %> - 往界面上输出一个变量的值 <%# Eval("属性名 ...

  6. webform之Repeater控件

    一.Repeater控件 数据循环编辑 1.repeater包括五大模板: (1)HeaderTemplate:标题模板,对开头进行编辑,只执行一次 (2)FooterTemplate:页尾结束模板, ...

  7. ASP.Net中通过Jquery前端对Repeater控件绑定的数据进行操作

    说明:由于Repeater控件是动态绑定,通过Id获取数据只能默认获取第一行: 1.对Repeater中div设置样式 2.通过$(".css").each(function(){ ...

  8. Repeater 控件

    Repeater 控件是一个容器控件,可用于从网页的任何可用数据中创建自定义列表.Repeater 控件没有自己内置的呈现功能,这意味着用户必须通过创建模板来提供 Repeater 控件的布局.当网页 ...

  9. Repeater控件用法

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Repeater.aspx. ...

随机推荐

  1. Android 学习第10课,Android的布局

    Android的布局 线性布局

  2. Objective-c——UI基础开发第十二天(相册展示)

    一.知识点 模仿新特性 UICollectionViewFlowLayout自定义布局 相册 瀑布流(淘宝购物之类的 二.复习 a.UICollectionView 和 tableview共享一套AP ...

  3. isinstance(),issubclass()

    isinstance(object,classinfo) 返回True,如果object是classinfo或者classinfo子class的实例. 如果classinfo是包含type和class ...

  4. LeetCode【169. Majority Element】

    Given an array of size n, find the majority element. The majority element is the element that appear ...

  5. 20160113 JS中CheckBox如何控制全选

    //判断CheckBoxzong他的点击事件 $("#CheckBoxzong").click(function () { //取出所有class为选中的集合 var query ...

  6. selenium下拉框选择

    下拉框结构如下,我需要选择的是new: html为: <select id="condition_type" name="condition_type" ...

  7. nodejs-基本语法

    初识nodejs-基本语法 nodejs是JavaScript的一个在后端的运行环境,关于nodejs的认识,我们可以看上一篇文章<<初识nodejs>>,我们要使用nodej ...

  8. 生成freemarker静态页面的工具类

    package cn.bocai.pc.util; import java.io.BufferedWriter;import java.io.File;import java.io.FileOutpu ...

  9. ef执行记录原生态代码方法。

    select e; var f = (System.Data.Objects.ObjectQuery<SimpleEntry>)final; var s = f.ToTraceString ...

  10. iframe 加载完成事件

    <body onload="load()"> <iframe id="iframe" frameborder="0" sc ...