【问题标题】:DataBinding from Entity Framework to Listivew dataSource从实体框架到 Listivew 数据源的数据绑定
【发布时间】:2011-10-15 16:19:36
【问题描述】:

我的实体返回以下内容:

class StoreClass{

    public Entry GetStoreInfo(int id, UserInfo userInfo)
    {
       using (var context = new StoreEntities())
       {
          var query = from a in context.Store
            .Include("Ratings")
            .Include("Versions")
            .Include("Versions.Installers")
            .Include("Versions.Installers.Screenshots")
            .Include("Category")
            where a.ID == id && a.IsActive 
         select a;
    return query.FirstOrDefault();
             }
    }
    }

我正在尝试将上述函数返回的数据数据绑定到列表视图。

StoreClass objStore = new StoreClass ();
            Listview1.DataSource = objStore .GetStoreInfo(1,userInfo);
            LstAppletInfo.DataBind();
        }

但它抛出错误“数据源是无效类型。它必须是 IListSource、IEnumerable 或 IDataSource。”

帮我解决这个问题!!!

【问题讨论】:

    标签: asp.net entity-framework listview


    【解决方案1】:
    public IEnumerable<Entry> GetStoreInfo(int id, UserInfo userInfo) 
    { 
        ...
        return query; 
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 2012-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多