最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

 更新時間:2012年11月23日 11:24:32   作者:  
在項目開發(fā)過程中,會經(jīng)常遇到ASP.NET repeater控件添加序號列,有些新手可能還不會,網(wǎng)上搜集整理了一些,需要的朋友可以參考下
在項目開發(fā)過程中,會經(jīng)常遇到ASP.NET repeater控件添加序號列,有些新手可能還不會,網(wǎng)上搜集整理了一些,需要的朋友可以參考下

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、后臺實(shí)現(xiàn)方法
在.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);
}
}
根據(jù)條件添加html
<%#Container.ItemIndex == 8 ? "<br><a target='_blank'><img style='width:338px;heigh:70px' src='/ImportAD/ADmid.gif'> </a>" : ""%>

相關(guān)文章

最新評論

佛学| 塔城市| 沁阳市| 如皋市| 宁河县| 扶风县| 车致| 丽江市| 铜山县| 德阳市| 定兴县| 宽城| 永安市| 含山县| 新竹县| 会宁县| 鸡东县| 靖江市| 白河县| 肇东市| 高州市| 广昌县| 尼勒克县| 文昌市| 交口县| 阿克| 南岸区| 彭水| 三门县| 牟定县| 通许县| 公主岭市| 茌平县| 神池县| 定襄县| 镇康县| 徐水县| 游戏| 巫溪县| 治多县| 汽车|