ObjectDataSource的TypeName指定的类的文件必须放在App_Code中吗?我的Web项目的页面与后台是分离的,没有App_Code文件夹,这样怎么办向高手求教!

解决方案 »

  1.   


    <%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS" Assembly="Samples.AspNet.CS" %>
    <%@ Page language="c#" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html  >
      <head>
        <title>ObjectDataSource - C# Example</title>
      </head>
      <body>
        <form id="Form1" method="post" runat="server">        <asp:gridview
              id="GridView1"
              runat="server"
              datasourceid="ObjectDataSource1" />        <asp:objectdatasource
              id="ObjectDataSource1"
              runat="server"
              selectmethod="GetAllEmployees"
              typename="Samples.AspNet.CS.EmployeeLogic" />    </form>
      </body>
    </html>
    看看这个就明白了
      

  2.   

    没有好用,抛了个异常:
    The type specified in the TypeName property of ObjectDataSource 'ObjectDataSource1' could not be found.why?
      

  3.   

    <%@ Register Assembly="AVAdminGui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f3d6e4baf0335fde"
        Namespace="AV.Protection.AdminGui" TagPrefix="Symc" %><asp:ObjectDataSource ID="ServerDataSource" runat="server" SelectMethod="GetDataSource" TypeName="AV.Protection.AdminGui.AVDataSource"></asp:ObjectDataSource>    <SharePoint:SPGridView ID="FrontEndServerList" DataSourceID="ServerDataSource" runat="server" AutoGenerateColumns="False"  FilterDataFields=",Status,Address" FilteredDataSourcePropertyFormat="{1} = '{0}'" AllowFiltering="True"  AllowSorting="True" border="0" BorderStyle="None" CssClass="ms-listviewtable" DataBoundHasBeenRaised="False" EmptyDataText="There are no items to show in this view." GridLines="None"  Width="100%">    
        <Columns>
            <SharePoint:SPMenuField HeaderText="Server Name" MenuTemplateId="mtProduct" SortExpression="Name" TextFields="Name" TokenNameAndValueFields="PNAME=Name" NavigateUrlFields="Name" NavigateUrlFormat="#Name-{0}" />
            <SharePoint:SPBoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
            <SharePoint:SPBoundField DataField="Address" HeaderText="Address\Computer name" SortExpression="Address" />
        </Columns>    <SelectedRowStyle CssClass="ms-selectednav" Font-Bold="True" />
        <AlternatingRowStyle CssClass="ms-alternating" />
    </SharePoint:SPGridView>
    <SharePoint:MenuTemplate ID="mtProduct" runat="server">
    <SharePoint:MenuItemTemplate ID="mitView" runat="server" Text="Deploy Now" ClientOnClickNavigateUrl="?Server=%PNAME%" />
    </SharePoint:MenuTemplate>
    上面是页面代码,在后台抛的异常:The type specified in the TypeName property of ObjectDataSource 'ObjectDataSource1' could not be found. 
      

  4.   

    ObjectDataSource的TypeName指定的类的文件不是必须放在App_Code中的,你可以建成项目文件即可以把TypeName里面的BLL类放在BLL层类库项目里。ObjectDataSource的TypeName通过反射得到数据源的。但我也在所有的页面查询时出现了The type specified in the TypeName property of ObjectDataSource 'ObjectDataSource1' could not be found的错误,是GridView绑定的,觉得没问题的啊,待解决啊~~
      

  5.   

    KingOfBall.BLL.KFB_LHCBSKG_BILL這是我的typyname,其實,這個不用放在App_Code中,只需要你把該類的引用寫全就行了。