VS2010, .Net 4.0
In trying to extend the asp.net BoundField server control, as described here:
http://iridescence.no/post/FixingBoundFieldSupportforCompositeObjects.aspx
I have created a class:
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);
}
}
}
I've registered it from my page:
<%@ Register TagPrefix="cc" Namespace="CustomControls" %>
...and on that page, I am attempting to use it like so:
<asp:GridView ID="gridDataSource" runat="server">
<Columns>
<cc:CompositeBoundField DataField="Application.ApplicationName" HeaderText="ApplicationName" />
</Columns>
</asp:GridView>
However, I am getting a compiler warning:
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.
And when I run, I get the error:
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'.
Any ideas what I'm doing wrong?
I tried this:
http://blog.tentaclesoftware.com/archive/2010/07/21/95.aspx
In the Register declaration, the Assembly is mandatory:
<%@ Register Namespace="CustomControls" TagPrefix="cc" Assembly="MyCompany.MyApp.WebApp" %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With