我做了以下事情:
可以看到我在bal.cs中的所有ObjectDataSource控件都看不到这个类。 怎么办??????????? !!!!
using System;
using System.Collections.Generic;
using System.Linq;
using Data;
public class BAL
{
public List<String> GetCountries()
{
using (var context = new NORTHWINDDataContext())
{
return (from c in context.customers
select c.country).Tolist();
}
}
public List<customer> GetCustomersByCountry(string country)
{
using (var context = new NORTHWINDDataContext())
{
return (from c in context.customers
where c.country == country
select c).Tolist();
}
}
public customer GetCustomer(string custID)
{
using (var context = new NORTHWINDDataContext())
{
return (from c in context.customers
where c.CustomerID == custID
select c).singleOrDefalt();
}
}
}
答案 0 :(得分:1)
手动配置ObjectDataSource
:
<asp:ObjectDataSource id="someid" runat="server" TypeName="BAL"
SelectMethod="GetCountries">
</asp:ObjectDataSource>
答案 1 :(得分:1)
尝试在App_Code文件夹中查看类的属性。
如果文件&#34; Build Action&#34;被设置为&#34;内容&#34;然后这似乎发生了。 一旦你将类更改为&#34;编译&#34;它将开始出现在ObjectDataSource列表中