在项目开发过程中,会经常遇到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. [Shell]Bash基本功能:通配符与特殊符号

    /*------------------------------------------------------------------------------------------- @黑眼诗人 ...

  2. Webservice之axis

    根据wsdl的url,使用axis1.4生成客户端,并且对webservice进行调用   1.到www.apache.org上去下载axis-bin-1_4.zip,如要关联源代码就把axis-sr ...

  3. BindingFlags 枚举

    https://msdn.microsoft.com/zh-cn/library/cexkb29a 官方解释: 指定控制绑定和由反射执行的成员和类型搜索方法的标志. 此枚举有一个 FlagsAttri ...

  4. java-学习4

    一.八大数据类型—dataType 整型 1)byte 2)short 3)int 4)long 浮点型 5)float 6)double 字符型 7)char 布尔型 8)boolean 二.变量和 ...

  5. 对于“2017面向对象程序设计(JAVA)第四周学习总结”存在问题的反馈

    对于“2017面向对象程序设计(JAVA)第四周学习总结”存在问题的反馈 “这部分同学博文总结没有写,实验作业没有提交.”——1.关于博文作业.实验作业教学功能的正解:学习知识.暴露问题.衔接课上.2 ...

  6. java.lang.NoClassDefFoundError: net.tsz.afinal.FinalHttp

    java.lang.NoClassDefFoundError: net.tsz.afinal.FinalHttpat com.hbjyjt.oa.utils.i.<init>(HttpRe ...

  7. vue 学习1

    .static{ border-radius:4px; } .active { width: 100px; height: 100px; background: green; } .text-dang ...

  8. SQLServer 学习笔记 序

    邀月的博客 http://www.cnblogs.com/downmoon/archive/2011/03/10/1980172.html

  9. metasploit framework(二):记一次入侵

    msfconsole use 其中一个 exploit前台执行注入 后台执行shell 加-j 通过sessions查看后台执行的shell,可以看到这个会话的id号为2 进入会话,sessions ...

  10. CRM销售管理功能

    联系项目project:-------是一个大的项目,比如通知开会之类 每个坐席需要分配自己的联系任务,每个联系任务,有自己的完成未完成状态.同时关联着通话记录等 销售计划----销售项目 销售流程: ...