Losing parent key value in User Control with Grid for manuall CRUD operations after the first postback/request

3 posts, 1 answers
  1. Rhonda
    Rhonda avatar
    2 posts
    Member since:
    Jan 2014

    Posted 29 Jan 2015 Link to this post


    I'm starting using Telerik controls and In a WEB page I have a RadGrid control that calls a User Control containing another RadGrid which it wants to be used for manual CRUD operations and it  requires the Parent Key value. In the User Control NeedDataSource event is used to assign/create the DataSource for the RadGrid, retrieving the Parent Key value from DataItem and passing it as parameter, DataBinder.Eval(DataItem, "FailureNotificationId"). The User Control is displayed/shown with the DataSoruce content but after the first postback/request I get an error in NeedDataSource event indicating the parameter (Parent Key value)
    was not provided to get the content for the DataSource because the DataItem value was lost.

    So, How to keep Parent Key value after postback/request in User Control?
  2. Answer
    Eyup avatar
    3322 posts

    Posted 03 Feb 2015 Link to this post

    Hi Briken,

    You can use the following approach to achieve this requirement:
    <MasterTableView ... DataKeyNames="OrderID">
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        GridEditableItem container = this.NamingContainer as GridEditableItem;
        string value = container.GetDataKeyValue("OrderID").ToString();

    Hope this helps. Please give it a try and let me know if it works for you.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. Rhonda
    Rhonda avatar
    2 posts
    Member since:
    Jan 2014

    Posted 08 Feb 2015 in reply to Eyup Link to this post

    Hi Eyup,

    It worked perfectly.Thanks for your help.

    Best regards!
Back to Top