This is a migrated thread and some comments may be shown as answers.

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

2 Answers 19 Views
Documentation and Tutorials
This is a migrated thread and some comments may be shown as answers.
Rhonda
Top achievements
Rank 1
Rhonda asked on 29 Jan 2015, 08:39 PM
Hi,

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 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 03 Feb 2015, 11:37 AM
Hi Briken,

You can use the following approach to achieve this requirement:
<MasterTableView ... DataKeyNames="OrderID">
C#:
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.

Regards,
Eyup
Telerik
 

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.

 
0
Rhonda
Top achievements
Rank 1
answered on 08 Feb 2015, 09:40 PM
Hi Eyup,

It worked perfectly.Thanks for your help.

Best regards!
Tags
Documentation and Tutorials
Asked by
Rhonda
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Rhonda
Top achievements
Rank 1
Share this question
or