2011-05-18 76 views
3

VS2010,.NET 4.0元素'CompositeBoundField'不是已知元素。 (试图延长的BoundField服务器控制)

在试图延长asp.net绑定列服务器控制,如下所述:
http://iridescence.no/post/FixingBoundFieldSupportforCompositeObjects.aspx

我已经创建了一个类:

using System.Web.UI; 
using System.Web.UI.WebControls; 

namespace CustomControls 
{ 
    public class CompositeBoundField : BoundField 
    { 
     protected override object GetValue(Control controlContainer) 
     { 
      object item = DataBinder.GetDataItem(controlContainer); 
      return DataBinder.Eval(item, this.DataField); 
     } 
    } 
} 

我已经从我的网页注册吧:

<%@ Register TagPrefix="cc" Namespace="CustomControls" %> 

...并在该网页上,我试图使用它,像这样:

<asp:GridView ID="gridDataSource" runat="server"> 
    <Columns> 
     <cc:CompositeBoundField DataField="Application.ApplicationName" HeaderText="ApplicationName" /> 
    </Columns> 
    </asp:GridView> 

但是,我得到一个编译器警告:

Element 'CompositeBoundField' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.  

当我跑,我得到的错误:

Parser Error 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Unknown server tag 'cc:CompositeBoundField'. 

任何想法我做错了什么?

我尝试这样做:
http://blog.tentaclesoftware.com/archive/2010/07/21/95.aspx

回答

4

在注册声明,大会是必需的:

<%@ Register Namespace="CustomControls" TagPrefix="cc" Assembly="MyCompany.MyApp.WebApp" %> 
0

检查大会属性包含完整强大的名字,例如: Assembly =“MyCompany.MyApp.WebApp,Version = 3.42.0.0,Culture = neutral,PublicKeyToken = 674cf0e5bf72fa08”

相关问题