OnNeedDataSource and OnFilterCheckListItemsRequested in C#

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

    Posted 26 Jan Link to this post

    Hello,

     

    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"
            OnFilterCheckListItemsRequested="RadGrid2_FilterCheckListItemsRequested">

     

    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:

    RadGrid2.OnNeedDataSource
    RadGrid2.OnFilterCheckListItemsRequested

    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
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 28 Jan 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.

    Regards,
    Viktor Tachev
    Telerik
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top