脚本宝典收集整理的这篇文章主要介绍了ASP.NET repeater添加序号列的方法,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
在项目开发
过程中,会经常遇到ASP.NET re
PEater控件添加序号列,有些
新手可能还不会,网上搜集整理了一些,需要的
朋友可以参考下
ASP.NET repeater添加序号列的方法
1、<ITemtemplate> <tr><td>
<%
# Cont
ainer.ItemIndex + 1%>
</td></tr>
</itemtemplate>
2、<itemtemplate> <tr><td>
<%# this.r
PResult.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].innerHT
ML=i+1;
}
}
</script>
4、后台实现方法:
在.aspx里添加<asp:Label id="Label1" Runat="server"></asp:Label>
在.cs里添加
** void Initialize
component()
{
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.RepeaterItemEvent
args 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;h
eigh:70px' src='/ImportAD/ADmid.gif'> </a>" : ""%>
脚本宝典总结
以上是脚本宝典为你收集整理的ASP.NET repeater添加序号列的方法全部内容,希望文章能够帮你解决ASP.NET repeater添加序号列的方法所遇到的问题。
如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。