Let's say I have a GridViewEx
class declared which extends GridView
. And inside that class, I have a delegate declared called GetDataPage
. So it look like this:
public class GridViewEx : GridView
{
public delegate object GetDataPageDelegate(int pageIndex, int pageSize, string sortExpression,
IList<FilterItem> filterItems);
[Browsable(true), Category("NewDynamic")]
[Description("Method used to fetch the data for this grid")]
public GetDataPageDelegate GetDataPage
{
get
{
return ViewState["pgv_getgriddata"] as GetDataPageDelegate;
}
set
{
ViewState["pgv_getgriddata"] = value;
}
}
// ... other parts of class omitted
}
This works ok and does what I want. But what I would like to be able to do is in the markup for the GridViewEx, be able to set this delegate, like so:
<div style="margin-top: 20px;">
<custom:GridViewEx ID="gridView" runat="server" SkinID="GridViewEx" Width="40%" AllowSorting="true"
VirtualItemCount="-1" AllowPaging="true" GetDataPage="Helper.GetDataPage">
</custom:GridViewEx>
</div>
However, I get this error:
Error 1 Cannot create an object of type 'GUI.Controls.GridViewEx+GetDataPageDelegate' from its string representation 'Helper.GetDataPage' for the 'GetDataPage' property.
I guess it's not possible to set it via markup, but I just wondered. It's easy enough to set the delegate in code, but I was just trying to learn something new. Thanks for any help.