2011-12-14 41 views
1

业务对象,我做了以下内容:ObjectDataSource控件无法看到的app_code

  1. 创建一个简单的网站
  2. 添加在App_Data文件夹
  3. NORTHWIND数据库连接创建的app_code业务对象文件夹
  4. bal.cs商业对象在app_code中的biz文件夹中的类
  5. 在app_code中创建数据文件夹linq to sql drag Ë客户表中有
  6. 创建一个新的page.aspx
  7. 阻力在下拉列表
  8. 配置数据源
  9. 一个ObjectDataSource添加到页面中BAL我的ObjectDataSource控件

无可以看到.cs可以看到这个类。 做什么??????????? !!!!

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(); 
     } 
    } 
} 

回答

1

手动配置ObjectDataSource

<asp:ObjectDataSource id="someid" runat="server" TypeName="BAL" 
         SelectMethod="GetCountries"> 
</asp:ObjectDataSource> 
+0

感谢您的回放,我在.aspx页面中完成了此操作,并且class bal出现了,但在bal类中,当我将其属性更改为编译它会生成一个错误错误无法找到类型或名称空间名称'Customer'(您是否缺少使用指令或程序集引用?) – 2011-12-14 19:47:05

1

尝试在App_Code文件夹类的属性。

如果文件“构建行动”设置为“内容”,那么这似乎发生。 只要您将类更改为“编译”,它就会开始显示在ObjectDataSource列表中

相关问题