如何在repeater里添加序號

2022-06-01    分類: 網(wǎng)站建設

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、

后臺實現(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);
   }
}

網(wǎng)頁題目:如何在repeater里添加序號
分享URL:http://www.bm7419.com/news44/162294.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供用戶體驗、App設計定制網(wǎng)站、做網(wǎng)站、外貿(mào)網(wǎng)站建設、軟件開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站