如何在repeater里添加序號(hào)

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

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、

后臺(tái)實(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);
   }
}

網(wǎng)頁(yè)題目:如何在repeater里添加序號(hào)
分享URL:http://www.muchs.cn/news44/162294.html

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

廣告

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

成都做網(wǎng)站