本文介绍了ObjectDataSource和ITypedList的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Hello group, 我有ObjectDataSource和ITypedList的问题。 在这个条目的末尾你找到我的List类的实现, 派生自ArrayList并实现ITypedList。列表中包含的所有项目都是类型为Person的类型,这是一个从无任何内容派生的类, 实现没有接口。 我放了一个我的表单上的DataSourceObject和Gridview。 DataSourceObject的 选择方法是GetAllPersons。 现在问题:运行表单时我看到有三列的网格 类Person的公共属性,以及列表中的项目。但我确实没有在设计时看到这个。 感谢任何帮助。 问候 Norbert Ruessmann [DataObject(true)] 公共类PersonsInArrayList:ArrayList,ITypedList { public PersonsInArrayList() { this.Add(new Person(1," James"," Cook")); } public ArrayList AllPersons() { 返回此; } #region ITypedList会员 公共PropertyDescriptorCollection GetItemProperties(PropertyDescriptor [] listAccessors) { PropertyDescriptorCollection propsColl = TypeDescriptor.GetProperties(typeof(Person)); 返回propsColl; } 公共字符串GetListName(PropertyDescriptor [] listAccessors) { Debug.WriteLine(" PersonInArrrayList :: GetListName") ; re转GrossElternCollection; } #endregion }Hello group,I have a problem with ObjectDataSource and ITypedList.At the end of this entry you find the implementatiopn of my List class,derived from ArrayList and implementing ITypedList. All items contained inthe list are of type Person, which is a class derived from nothing andimplementing no Interfaces.I put a DataSourceObject on my form and a Gridview. The DataSourceObject''sselect method is GetAllPersons.Now the problem: when running the form I see the grid with three columns forthe public properties of class Person, and the items of the list. But I donot see this at design time.Any help is appreciated.RegardsNorbert Ruessmann[DataObject(true)]public class PersonsInArrayList : ArrayList , ITypedList{public PersonsInArrayList(){this.Add (new Person( 1 , "James" , "Cook" ));}public ArrayList AllPersons(){return this;}#region ITypedList Memberspublic PropertyDescriptorCollectionGetItemProperties(PropertyDescriptor[] listAccessors){PropertyDescriptorCollection propsColl=TypeDescriptor.GetProperties(typeof(Person));return propsColl;}public string GetListName(PropertyDescriptor[] listAccessors){Debug.WriteLine("PersonInArrrayList :: GetListName");return "GrossElternCollection";}#endregion}推荐答案 这篇关于ObjectDataSource和ITypedList的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-15 14:18