做了一个封装,使页面更容易维护一些。主要是两个方法,如下所示:
private void BindModule(Action<Repeater, string> bindSingRpt) { BindControls(this, "List_", bindSingRpt); } private void BindControls(Page page, String prefix, Action<Repeater, string> bindSingControl) { var controlList = page.Controls; foreach (Control control in controlList) { if (control.ID != null && control.ID.StartsWith(prefix) && control is Repeater) { var suffix = control.ID.Split(‘_‘)[1]; if (prefix == "List_") bindSingControl(control as Repeater, suffix); } } }
时间: 2024-10-20 01:43:03