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

When to insert a dynamically created UC into a control

2 Answers 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 2
Richard asked on 13 Feb 2009, 07:36 PM
I have created a class that builds a custom grid object (StandardGrid).  In addition to that I have created a user control that I want to insert into the FilteringItem of the grid object.  When the user clicks on the button inside the user control I want to perform an action on the grid.  I'm not sure how to hook things up properly.  Here's what I currently have happening.  The GridFilterButton (user control) inserts fine into the grid initially but then isn't available on postback.  Any help would be appreciated.

 

 

 

void StandardGrid_ItemCreated(object sender, GridItemEventArgs e)

{

 

switch (e.Item.ItemType)

{

 

case

 

 

GridItemType.FilteringItem:

 

GridFilteringItem filteringItem = e.Item as GridFilteringItem;


try 
 

 

 

{

 

//Insert the GridFilterButton @ position 0 in the Grid

 

Control GridFilterButton = this.Page.LoadControl("~\\UserControls\\GridFilterButton.ascx");

filteringItem[

"CommandColumn"].Controls.AddAt(0, GridFilterButton);

 

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 16 Feb 2009, 05:45 AM
Hi Richard,

Are you binding the Grid using AdvanceDataBinding techniques ? If not you need to manually bind the Grid after every postback.

Thanks
Shinu.
0
Sebastian
Telerik team
answered on 16 Feb 2009, 08:31 AM
Hi guys,

You can specify CommandName value for the button which resides in the user control used for filtering and intercept the command when it is pressed taking advantage of the event bubbling mechanism of RadGrid. Note that the ItemCreated event will be raised on each submit as explained in this help topic.

Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Richard
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Sebastian
Telerik team
Share this question
or