博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ASP.NET repeater添加序号列的方法
阅读量:4307 次
发布时间:2019-06-06

本文共 1235 字,大约阅读时间需要 4 分钟。

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>" : ""%>

 

转载于:https://www.cnblogs.com/vera/archive/2012/12/05/2802981.html

你可能感兴趣的文章
centos安装coreseek
查看>>
gitlab应用
查看>>
$Django importlib与dir知识,手写配置文件, 配置查找顺序 drf分页器&drf版本控制
查看>>
对layoutInflater的理解
查看>>
网络流之最大流问题
查看>>
【自己给自己题目做】之一:椭圆可点击区域
查看>>
Uva 1625 - Color Length(DP)
查看>>
练习2-1 Programming in C is fun!
查看>>
isset函数
查看>>
混合app
查看>>
centos下crontab的使用
查看>>
HTMLParser-实战
查看>>
分布式之缓存击穿
查看>>
从头认识Spring-1.7 如何通过属性注入Bean?(1)-如何通过属性向对象注入值?...
查看>>
$Poj1952\ $洛谷$1687\ Buy\ Low,Buy\ Lower$ 线性$DP+$方案计数
查看>>
linux文件夹打包命令
查看>>
运行cmd状态下MySQL导入导出.sql文件
查看>>
Hbase时间同步
查看>>
HBase1.0.0 实现数据增删查
查看>>
webpack4 入门配置研究
查看>>