New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Access DataItem from the topmost Grid from UserControl EditForm

DESCRIPTION

How to access the DataItem of the parent RadGrid from a WebUserControl EditForm. How to do this in a nested scenario where one edit form can contain another grid and the third-level grid needs data from the top-level grid.

SOLUTION

The grid populates the data item object when the edit/insert command is invoked (see the Edit Form Types demo). Subsequent postbacks may not populate it.

You can store the data in the ViewState of the user control when it loads initially, or the Session

Alternatively, you can traverse the control hierarchy of the grids and user controls and use the GetDataKeyValue() method the grid items expose to fetch data. You can find a small example of this attached below. Make sure to add the necessary fields in the DataKeyNames collection of the MasterTableView.

DOWNLOAD the sample: grid-nested-ucs.zip

In this article
Not finding the help you need? Improve this article