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