事件委托,当此类(继承自Repeater)加载时,执行某方法!!
事件委托,当此类(继承自Repeater)加载(Load事件)时,执行DBind方法!!
public class Repeat2: Repeater { public void DBind(object sender, EventArgs e) { this.DataSource = a; this.DataBind(); }} public class Repeat2: Repeater { public void DBind(object sender, EventArgs e) { this.Load += new EventHandler(DBind);//这样不行?? this.DataSource = a; this.DataBind(); }}public class Class1: Repeater { protected override void OnLoad(EventArgs e) { base.OnLoad(e); //todo: 增加你的代码 } public Class1() { this.Load += new EventHandler(Class1_Load); } void Class1_Load(object sender, EventArgs e) { //todo: 增加你的代码 }}
[解决办法]
语法问题,学习.