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