• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
make a different
博客园    首页    新随笔    联系   管理    订阅  订阅
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);
   }
}

posted on 2010-08-07 17:44  雨荨  阅读(8595)  评论(2)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3