• Reaper自定义模板


    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Collections.Generic;

    namespace WebApplication1
    {
        public partial class _Default : System.Web.UI.Page
        {
            public class NumberLinkTemplate : ITemplate
            {

                #region ITemplate 成员

                public void InstantiateIn(Control container)
                {
                    LinkButton lb = new LinkButton();
                    lb.CommandName = "Index";
                    Literal lt = new Literal();
                    lt.Text = " ";
                    container.Controls.Add(lb);
                    container.Controls.Add(lt);
                    lb.DataBinding += new EventHandler(lb_DataBinding);
                }

                void lb_DataBinding(object sender, EventArgs e)
                {
                    LinkButton lbtn = (LinkButton)sender;
                    RepeaterItem container = (RepeaterItem)lbtn.NamingContainer;
                    lbtn.Text = container.DataItem.ToString();
                    lbtn.CommandArgument = container.DataItem.ToString();
                }

                #endregion
            }

            protected void Page_Load(object sender, EventArgs e)
            {
                List<string> linkNumberDataSource = new List<string>();
                for (int i = 1; i <= 10; i++)
                {
                    linkNumberDataSource.Add(i.ToString());
                }

                Repeater enterpriseRep = new Repeater();
                enterpriseRep.ItemTemplate = new NumberLinkTemplate();
                enterpriseRep.DataSource = linkNumberDataSource;
                enterpriseRep.DataBind();
                enterpriseRep.ItemCommand += new RepeaterCommandEventHandler(enterpriseRep_ItemCommand);
                this.Panel1.Controls.Add(enterpriseRep);
               
            }

            void enterpriseRep_ItemCommand(object source, RepeaterCommandEventArgs e)
            {
                Response.Write("CommandName:"+e.CommandName+"<br>"+"CommandArgument:"+e.CommandArgument);
            }
        }
    }

  • 相关阅读:
    Mysql 8.0 OCP认证考试原题题库整理(CUUG内部资料)-第2题
    Mysql 8.0 OCP认证考试原题题库整理(CUUG内部资料)-第1题
    【2020年8月】Oracle OCP 062考试新题(-3题)CUUG内部题库
    【2020年8月】Oracle OCP 062考试新题(-2题)CUUG内部题库
    iOS7时代我们用什么来追踪和识别用户?
    插件就是生产力——那些不能错过的XCode插件们
    批处理执行Testng
    Jmeter调度器小记
    Newtonsoft.Json小记
    批处理添加环境变量
  • 原文地址:https://www.cnblogs.com/chenfulai/p/1353555.html
Copyright © 2020-2023  润新知