北京尚网汇智科技有限公司
您当前所在的位置:尚网汇智网站建设 > ASP.NET技术 > 文章详细
网站建设知识
NEWS
联系我们
  • 网站建设服务电话
  • 400-883-2887
  • 公司地址:北京市昌平科技园区创意大厦2-806
  • 服务项目
    高端网站建设
    移动/微信网站建设
    手机APP开发
    OA/ERP业务系统开发
    网站维护托管
    CMS模板制作

    如何在repeater里添加序号

    发布时间:2013-04-04 22:11:52

    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);
       }
    }


    文章出自:北京网站建设公司-尚网汇智 https://www.net2006.com 如转载请注明出处!
    咨询服务热线
    400-883-2887
    客服电话:400-883-2887  传真:010-51654992  E-mail:support@net2006.com
    本站设计已受版权保护,任何公司及个人不得复制,违者将依法追究责任,特此声明。

    Copyright © 2005-2018 北京尚网汇智科技有限公司 版权所有 京ICP备13031271号
    查找内容: