public WebDataSourceView(WebDataSource owner, string viewName) : base(owner, viewName) { _owner = owner; _viewName = viewName; }
private WebDataSource GetMasterDataSource(WebDataSource owner) { if (owner.IsMaster)//当前就是Master { return owner; } else { if (owner.MasterDataSourceID == owner.ID) { //MasterDataSource不能是自己本身,会造成死循环 throw new Exception("MasterDataSource can not be self."); } Control parent = owner.Parent.FindControl(owner.MasterDataSourceID); if (parent != null && parent is WebDataSource) { return GetMasterDataSource(parent as WebDataSource);//递归直到最顶层 } else { throw new Exception(string.Format("can not find datasource:'{0}'", MasterDataSourceID)); } } }