蓝嗄燠痄,张也被执行死刑后照片,吴国秀
在项目开发过程中,会经常遇到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>" : ""%>
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
网友评论