【发布时间】:2015-03-13 15:41:35
【问题描述】:
我正在尝试将数量分组并加载到 vb.net (asp.net) 中的下拉框中
但我收到以下错误:
不支持直接将数据绑定到存储查询(DbSet、DbQuery、DbSqlQuery、DbRawSqlQuery)。而是使用数据填充 DbSet,例如通过在 DbSet 上调用 Load,然后绑定到本地数据。对于 WPF 绑定到 DbSet.Local。对于 WinForms 绑定到 DbSet.Local.ToBindingList()。对于 ASP.NET WebForms,您可以绑定到在查询上调用 ToList() 的结果或使用模型绑定,有关详细信息,请参阅
我的代码:
'Load Amounts
Dim SourceAmounts = (From p In db.PayoutAdjustments
Order By p.Amount
Where p.PayoutId = PayoutId
Group p By Key = p.Amount Into Group
Select Amount = Group)
cmbAmount.DataSource = SourceAmounts
cmbAmount.DataTextField = "Amount"
cmbAmount.DataValueField = "Amount"
cmbAmount.DataBind()
cmbAmount.Items.Insert(0, New ListItem("Select Amount", 0))
【问题讨论】:
标签: asp.net vb.net entity-framework