Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 904069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:59:24+00:00 2026-05-15T15:59:24+00:00

Let’s say I have a GridViewEx class declared which extends GridView . And inside

  • 0

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.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:59:25+00:00Added an answer on May 15, 2026 at 3:59 pm

    It sounds like what you really want to do is expose an event. Add:

    public event GetDataPageDelegate GettingDataPage
    

    Then in your markup you’ll be able to say:

    <custom:GridViewEx ID="gridView" runat="server" SkinID="GridViewEx" Width="40%" AllowSorting="true" 
        VirtualItemCount="-1" AllowPaging="true" OnGettingDataPage="Helper.GetDataPage"> 
    </custom:GridViewEx>
    

    By “raising” the event in your DataBind method as such:

    if(GettingDataPage!=null)
       GettingDataPage(pageIndex,pageSize,sortExpression,filterItems);
    

    However, I would follow the pattern of events and create a new object:

    public class GettingDataPageEventArgs : EventArgs
    {
       public int PageIndex{get;set;}
       public int PageSize{get;set;}
       public string SortExpression{get;set;}
       public IList<FilterItem> FilterList{get;set;}
    }
    

    and change your delegate to

    public delegate void GettingDataPageEventHandler(object sender, GettingDataPageEventArgs);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say you have a class called Customer, which contains the following fields: UserName
Let me explain best with an example. Say you have node class that can
Let's say you have a class, with certain properties, and that you tried your
Let's say that I have two interfaces and a behavior class: public interface Creable
Let's say I have some variables declared - but I don't know exactly which,
Let's say I have a method in java, which looks up a user in
Let's say that I have a SQLite database that I create in a separate
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have multiple requirements for a password. The first is that the
Let's say that I have a date in R and it's formatted as follows.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.