我正在开发一个将 Object
转换为 IList
的应用程序。然后我想将它转换为 BindingList
这是我正在尝试的代码
IList data = spareEntity.getall() as IList;
var listBinding = new BindingList<IList>(data);
public object getall()
{
using (var worldbankAMSentitiesNew = new WorldBankAMSEntities())
{
var q = from fullSpareInventory in worldbankAMSentitiesNew.Spare_Inventory
select new
{
fullSpareInventory.Is_Spare,
fullSpareInventory.Manufacturer,
fullSpareInventory.Product_No,
fullSpareInventory.Remarks,
fullSpareInventory.Remedy_Ticket_No,
fullSpareInventory.Serial_No,
fullSpareInventory.Spare_Type,
fullSpareInventory.Spare_Inventory_Volume.Spare_Name,
fullSpareInventory.Spare_ID,
fullSpareInventory.Assigned_Date,
fullSpareInventory.Description,
fullSpareInventory.Spare_Volume_ID
};
return q.ToList();
}
}
最佳答案
你可以尝试如下:-
var yourList = spareEntity.getall() as List<Object>;
var listBinding = new BindingList<Object>(yourList);
关于c# - 无法将 IList 转换为绑定(bind)列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25262784/