OnNeedDataSource and OnFilterCheckListItemsRequested in C#

2 posts, 0 answers
  1. Sebastiaan
    Sebastiaan avatar
    4 posts
    Member since:
    Jan 2016

    Posted 26 Jan 2016 Link to this post



    I would like to set OnNeedDataSource and OnFilterCheckListItemsRequested in C# and not in aspx.


    When having this line in Default.aspx it all works fine:

    <telerik:RadGrid ID="RadGrid2" runat="server" Width="750px" OnNeedDataSource="RadGrid2_NeedDataSource"


    But I would like to get everything but ID and runat to Default.aspx.cs.

    Like so:

    RadGrid2.MasterTableView.DataKeyNames = new string[] { "ID" };
    RadGrid2.AllowPaging = true;
    RadGrid2.AllowSorting = true;
    RadGrid2.GroupingEnabled = true;
    RadGrid2.GroupPanelPosition = GridGroupPanelPosition.Top;
    RadGrid2.AllowFilteringByColumn = true;
    RadGrid2.FilterType = GridFilterType.HeaderContext;
    RadGrid2.EnableHeaderContextMenu = true;
    RadGrid2.EnableHeaderContextFilterMenu = true;


    But when adding these:


    I get an error saying these are inaccessible due to their protection level.

    So how can I assign RadGrid2_NeedDataSource and RadGrid2_FilterCheckListItemsRequested in C#?

  2. Viktor Tachev
    Viktor Tachev avatar
    2469 posts

    Posted 28 Jan 2016 Link to this post

    Hi Sebastiaan,

    In order to specify the settings for RadGrid you can use the Page_Load event. Check out the following article that describes the approach in more details.

    In addition I am attaching a sample project where the behavior is implemented. Give it a try and see how it works for you.

    Viktor Tachev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top