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

NestedView with UserControl

1 Answer 31 Views
Grid
This is a migrated thread and some comments may be shown as answers.
abonfig
Top achievements
Rank 1
abonfig asked on 24 Jun 2010, 07:46 PM
Are there any examples or does anyone have any guidelines for having a nestedviewtemplate that contains a usercontrol?  What I am looking to accomplish is the user expanding a row, and the expansion has a user control's data is based on a value ("key") from the row of data that was just expanded.  The control's data is retrieved on page load and is then stored in ViewState. 

If I do something like this:
<NestedViewTemplate> 
    <uc1:myControl runat="server" ID="myCustomControl" MyKey='<%# Eval("Key") %>' /> 
</NestedViewTemplate> 
 
everything seems to work OK until I try to edit a row in the grid or add a row.  At that point, the ViewState of the control is lost and since it's not an initial page load it won't re-load the data.

So I guess my questions would include:
1.  Anything I need to consider when using a UserControl in a NestedViewTemplate?
2.  Do I need to add the usercontrol dynamically?
3.  Do I need to load the data of the control in a different manner?  Upon grid row expansion, for example?

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 29 Jun 2010, 02:35 PM
Hi,

You can override the UserControl's DataBInding event in order to populate its nested controls values. I have attached a small sample which demonstrates a basic implementation.

Best wishes,
Rosen
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
abonfig
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or