在项目开发过程中,会经常遇到ASP.NET repeater控件添加序号列,有些新手可能还不会,网上搜集整理了一些,需要的朋友可以参考下

ASP.NET repeater添加序号列的方法

1、<itemtemplate> 
<tr><td> 
<%# Container.ItemIndex + 1%> 
</td></tr> 
</itemtemplate>

2、<itemtemplate> 
<tr><td> 
<%# this.rpResult.Items.Count + 1%> 
</td></tr> 
</itemtemplate>

3、在<form></form>中添加<Label ID="dd" ></Label> 
<body nload="show()"> 
<Script. Language="JScript"> 
function show() 

var bj = document.all.tags("LABEL"); 
for (i=0;i<obj.length;i++) 

document.all["dd"][i].innerHTML=i+1; 


</script>

4、后台实现方法: 
在.aspx里添加<asp:Label id="Label1" Runat="server"></asp:Label> 
在.cs里添加 
** void InitializeComponent() 

this.Repeater1.ItemDataBound += new System.Web.UI.WebControls.RepeaterItemEventHandler(this.Repeater1_ItemDataBound); 
this.Load += new System.EventHandler(this.Page_Load); 

** void Repeater1_ItemDataBound(object source, System.Web.UI.WebControls.RepeaterItemEventArgs e) 

if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) 

((Label)e.Item.FindControl("Label1")).Text = Convert.ToString(e.Item.ItemIndex + 1); 


根据条件添加html 
<%#Container.ItemIndex == 8 ? "<br><a href = 'http://www.ginchan.com.tw/' target='_blank'><img style='width:338px;heigh:70px' src='/ImportAD/ADmid.gif'> </a>" : ""%>

Repeater控件添加序号列的更多相关文章

  1. Repeater控件添加onmouseover和onmouseout事件

    网友有问题,在Repeater控件中,需要添加onmouseover和onmouseout事件功能.Insus.NET有叫他参考<onmouseover和onmouseout在Repeater控 ...

  2. GridControl控件添加按钮列及在按钮Click事件中得到行数据 zt

    在GridControl中添加按钮列的步骤如下: 1. 把列的ColumnEdit属性设置为RepositoryItemButtonEdit 2. 把TextEditStyle属性设置为HideTex ...

  3. repeater控件如何隐藏列?

    .aspX文件里将要隐藏的"<td>修改</td>"放在Lable标签里,隐藏实现,如:<asp:lable id=lable1 run=server ...

  4. 给Repeater控件里添加序号的5种方法

    Repeater是我们经常用的一个显示数据集的数据控件,经常我们希望在数据前显示数据的序号,那么我们该怎么为Repeater控件添加序号呢?下面编辑为大家介绍几种常用的为Repeater控件添加序号的 ...

  5. 动态合并Repeater控件数据列

    前天Insus.NET实现<动态合并GridView数据行DataRow的列>.今天再玩玩Repeater控件,功能也是动态合并某列栏位.Repeater控件跟GridView控件一样集成 ...

  6. 实现Repeater控件的记录单选

    有朋友问及,在Repeater控件中第一列放置一个RadioButton,实现对记录的单选. 下面Insus.NET想举个例子来实现与说明. 为Repeater控件准备数据: 在ASPX网页上,写好R ...

  7. {Repeater控件} Repeater控件的用法流程及实例

    一.Repeater控件的用法流程及实例: 1.首先建立一个网站,新建一个网页index.aspx. 2.添加或者建立APP_Data数据文件,然后将用到的数据库文件放到APP_Data文件夹中. 3 ...

  8. repeater中后台动态为控件添加属性

    在此贴出repeater中的ItemDataBound事件中的代码: private void ItemDataBound(object sender, RepeaterItemEventArgs e ...

  9. ASP.NET repeater添加序号列的方法

    ASP.NET repeater添加序号列的方法 1.<itemtemplate> <tr><td> <%# Container.ItemIndex + 1% ...

随机推荐

  1. 遍历DOM树,each()遍历

    在<jQuery教程/理解选取更新范围>一节中,我们知道:当选择器返回了多个元素时,可以使用一个方法来更新所有的元素,不再需要使用循环. 然后有的时候需要遍历元素,怎么办? 使用each( ...

  2. Python学习笔记(一)简介总览

    Class 1 一.简介 python:脚本语言.解释型语言 缩进是python语言很重要的一个标志 python3是未来的发展趋势 二.安装 windows: 1.下载安装包: https://ww ...

  3. Delphi动态调用C++写的DLL

    c++ DLL 文件,建议用最简单的c++编辑工具.不会加入很多无关的DLL文件.本人用codeblocks+mingw.不像 VS2010,DLL编译成功,调用的时候会提示缺其他DLL. 系统生成的 ...

  4. ArcGIS自定义工具箱-自增字段(可以设置初始值和步长)

    ArcGIS自定义工具箱-自增字段(可以设置初始值和步长) 联系方式:谢老师,135-4855-4328,xiexiaokui#qq.com 目的:字段值初始值为设定值(默认为0),每次增加一个步长( ...

  5. 吴裕雄 python 机器学习-KNN(2)

    import matplotlib import numpy as np import matplotlib.pyplot as plt from matplotlib.patches import ...

  6. java-学习3(jdk-环境配置)

    学习java先安装jdk环境配置 https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htm ...

  7. struts2漏洞信息

    渗透篇01-struts2漏洞利用  https://blog.csdn.net/qq_38055050/article/details/79841604 Struts2著名RCE漏洞引发的十年之思  ...

  8. Alpine Linux 使用简介

    https://blog.csdn.net/csdn_duomaomao/article/details/76152416

  9. Rx操作符

    [Rx操作符] 1.Observable.from()方法,它接收一个集合作为输入,然后每次输出一个元素给subscriber: Observable.from("url1", & ...

  10. yml和properties配置文件区别

    我们可以观察到的格式就是yml文件是梯级呈现的,我们应该注意一下几个方面: 1>在properties文件里面的 “ .”  连接在yml文件里面全部换成 ":" 进行连接, ...