| 
 
| 这是自定义控件里面的内容 
 
 这是前台的
 
 
 为什么在后台这样写不对?
 protected void Page_Load(object sender, EventArgs e)
 {
 string dataSource1 = "";
 
 NewsDataSource aaa = new NewsDataSource();
 aaa.ID = "focusnews";
 GetDataSource(dataSource1,aaa.ID);
 
 NewsDataSource bbb = new NewsDataSource();
 aaa.ID = "links1";
 GetDataSource(dataSource1,bbb.ID);
 
 NewsDataSource ccc = new NewsDataSource();
 aaa.ID = "links2";
 GetDataSource(dataSource1,ccc.ID);
 }
 private void GetDataSource(string datasource,string ucID)
 {
 ObjectDataSource ods = (ObjectDataSource)ucID.FindControl("odsID");
 ods.TypeName = datasource;
 Repeater rep = (Repeater)ucID.FindControl("repeaterID");
 rep.DataSourceID = "odsID";
 }
 如果直接写成ObjectDataSource ods = (ObjectDataSource)focusnews.FindControl("odsID");就对,这是为何?
 
 
 
 | 
 
1.jpg
(100.07 KB, 下载次数: 0)
 
 这是自定义控件里面的内容 
2.jpg
(59.4 KB, 下载次数: 0)
 
 这是前台的 |