1. 通过Repeater和数据源创建表格

<AlternatingItemTemplate>属性可以控制单元格交替显示不同的背景颜色

                   <table width="95%" align="center" bgcolor="#badde9" border="" cellspacing="" cellpadding=""
style="margin-top: 15px">
<tbody>
<tr>
<td width="16%" height="" align="center" class="a2" background="../../image/ttg.gif"
bgcolor="#dae8ed">
序号
</td>
<td width="16%" align="center" class="a2" background="../../image/ttg.gif" bgcolor="#dae8ed">
服务供应商
</td>
<td width="16%" align="center" class="a2" background="../../image/ttg.gif" bgcolor="#dae8ed">
服务项目名称
</td>
<td width="16%" align="center" class="a2" background="../../image/ttg.gif" bgcolor="#dae8ed">
客户姓名
</td>
<td width="16%" align="center" class="a2" background="../../image/ttg.gif" bgcolor="#dae8ed">
创建时间
</td>
<td align="center" class="a2" background="../../image/ttg.gif" bgcolor="#dae8ed">
操作
</td>
</tr>
<asp:Repeater ID="rpt1" runat="server"
onitemdatabound="rpt1_ItemDataBound">
<ItemTemplate>
<tr>
<td height="" bgcolor="#fafafa" align="center">
<%= number + (pageItems.CurrentPageIndex - ) * pageItems.PageSize%>
<% number++; %>
</td>
<td bgcolor="#fafafa" align="center">
<%# DataBinder.Eval(Container.DataItem, "ServiceObjectName")%>
</td>
<td bgcolor="#fafafa" align="center">
<%# DataBinder.Eval(Container.DataItem, "ServiceProjectName")%>
</td>
<td bgcolor="#fafafa" align="center">
<%# DataBinder.Eval(Container.DataItem, "ClientName")%>
</td>
<td bgcolor="#fafafa" align="center">
<%#Beyondbit.OA.Community.Common.Format.ShowTime(Eval("CreateTime"), "yyyy-MM-dd HH:mm:ss")%>
</td>
<td bgcolor="#fafafa" align="center">
<asp:HyperLink runat="server" ID="reviewHref" Text="回访" CssClass="button blue small"/>
<asp:Label ID="lblStatus" runat="server" Text="已完成" />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td height="" bgcolor="#f1f6f8" align="center">
<%= number + (pageItems.CurrentPageIndex - ) * pageItems.PageSize%>
<% number++; %>
</td>
<td bgcolor="#f1f6f8" align="center">
<%# DataBinder.Eval(Container.DataItem, "ServiceObjectName")%>
</td>
<td bgcolor="#f1f6f8" align="center">
<%# DataBinder.Eval(Container.DataItem, "ServiceProjectName")%>
</td>
<td bgcolor="#f1f6f8" align="center">
<%# DataBinder.Eval(Container.DataItem, "ClientName")%>
</td>
<td bgcolor="#f1f6f8" align="center">
<%#Beyondbit.OA.Community.Common.Format.ShowTime(Eval("CreateTime"), "yyyy-MM-dd HH:mm:ss")%>
</td>
<td bgcolor="#f1f6f8" align="center">
<asp:HyperLink runat="server" ID="reviewHref" Text="回访" CssClass="button blue small"/>
<asp:Label ID="lblStatus" runat="server" Text="已完成" />
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
<tr id="Tr1" runat="server" visible='<%#bool.Parse((rptUnAccetpPhone.Items.Count==0).ToString())%>'>
<td colspan="" height="" align="center" class="a2">
暂无数据!
</td>
</tr>
</FooterTemplate>
</asp:Repeater>
</tbody>
</table>

2. 让Repeater只重复显示一次

protected void rpt1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.Item.ItemIndex > )
e.Item.Visible = false;
}
}

3. Repeater控件没数据时显示"找不到任何数据"

<FooterTemplate>
<asp:Label ID="lbEmpty" Text="找不到任何数据!" ForeColor="Red" runat="server" Visible='<%#bool.Parse((YourRepeaterID.Items.Count==0).ToString())%>'>
</asp:Label>
</FooterTemplate>

asp.net控件(1)Repeater的更多相关文章

  1. 数据绑定控件之Repeater

    引言 前几篇的文章在说AJAX的内容,利用AJAX技术能够开发出高效运行的网站应用程序,不过在进行B/S项目开发时只拥有AJAX技术是远远不够的,踏入到B/S要学的东西会更多,但相较C/S的复杂逻辑结 ...

  2. ASP.NET控件的ID,ClientID,UniqueId的区别

    一般情况下三者相同(没有父控件) ID:获取或设置分配给服务器控件的编程标识符.分配给控件的编程标识符. (可写) 设置服务器控件上的此属性可提供对服务器控件的属性.事件和方法的编程访问.Web 开发 ...

  3. asp.net控件的异步刷新

    需求:我们知道,asp.net控件中的button控件,默认是开启了自己主动回发的,而有时候.我们不想刷新整个界面.而仅仅想局部刷新,可页面中又偏偏用到了.net button控件. 尽管我非常讨厌. ...

  4. asp.net <asp:Content>控件

    <asp:Content ID="Content2" ContentPlaceHolderID="CPH_MainContent" runat=" ...

  5. FineUI 基于 ExtJS 的专业 ASP.NET 控件库

    FineUI 基于 ExtJS 的专业 ASP.NET 控件库 http://www.fineui.com/

  6. ASP.NET控件<ASP:Button /> html控件<input type="button">区别联系

    ASP.NET控件<ASP:Button />-------html控件<input type="button">杨中科是这么说的:asp和input是一样 ...

  7. asp.net控件的Hyperlink控件

    Asp.net控件: Hyperlink控件:Hyperlink控件又称为超链接控件,该控件在功能上跟Html的<a herf=””>控件相似,其显示的模式为超链接的形式. 注意: Hyp ...

  8. asp.net控件开发基础(1)(转)原文更多内容

    asp.net本身提供了很多控件,提供给我们这些比较懒惰的人使用,我认为控件的作用就在此,因为我们不想重复工作,所以要创建它,这个本身便是一个需求的关系,所以学习控件开发很有意思. wrox网站上有本 ...

  9. 把某个asp.net 控件 替换成 自定义的控件

    功能:可以把某个asp.net 控件 替换成 自定义的控件 pages 的 tagMapping 元素(ASP.NET 设置架构) 定义一个标记类型的集合,这些标记类型在编译时重新映射为其他标记类型. ...

随机推荐

  1. C#学习笔记14:面向对象继承的特点和里氏转换

    面向对象: 继承:减少代码. 单根性  传递性 子类没有从父类那里继承了构造函数,只是会默认的调用父类那个无参数的构造函数 Class person { Public String Name { Ge ...

  2. Dojo Tree设置默认选中项并且获得它

    先上用来生成Tree的JSON数据 [    { "id": "Root", "name": "资源目录" },    ...

  3. ASP.NET生成日历

    public string GetDayList(DateTime? date) { ; var minDate = Convert.ToDateTime(((DateTime)(date ?? Da ...

  4. makefile文件制作入门

    一.首先,看一下最简单的C文件 //hello.c文件 #include <stdio.h> void main() { printf("hello world\n") ...

  5. ###STL学习--关联容器

    点击查看Evernote原文. #@author: gr #@date: 2014-08-23 #@email: forgerui@gmail.com STL中的关联容器. ###stl学习 |--迭 ...

  6. WPF的TextBox的焦点获取与失去焦点的死循环解决方案

    在WPF中实现一个弹出层自动获取焦点,弹出层实现是通过其UserControl的依赖属性Visibility的绑定实现的,让UserControl上的TextBox获取焦点,初始实现代码如下: pub ...

  7. 【mysql】【分组】后取每组的top2

    DROP TABLE IF EXISTS `tb1`; CREATE TABLE `tb1` ( `id` ) NOT NULL AUTO_INCREMENT, `a` ) DEFAULT NULL, ...

  8. css 利用border属性制作箭头 Using Borders to Make Pure CSS Arrows

    不再需要多余的图片 用border属性自然能创造箭头效果 学习地址:http://tech.patientslikeme.com/2010/11/09/using-borders-to-make-pu ...

  9. Java实战之04JavaWeb-06DBUtils

    一.DBUtils 1.DBUtils的简介 Commons DbUtils是Apache组织提供的一个对JDBC进行简单封装的开源工具类库,使用它能够简化JDBC应用程序的开发,同时也不会影响程序的 ...

  10. 暑假集训(3)第三弹 -----Til the Cows Come Home(Poj2387)

    题意梗概:据说母牛在产奶的时候,因为奶量太充足,希望有人帮它挤奶,它回家就很快.我们便能喝到鲜美的 牛奶,不过,贫奶季节却大不相同,它会懒洋洋的在大草原上晃来晃去的晒太阳,而不会想到马上回家,这可不 ...