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

How to capture event in Child in Hierarchy grid

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Officialboss
Top achievements
Rank 1
Officialboss asked on 13 Sep 2008, 11:25 PM
I have a 2-Level hierarchy grid binding with ObjectDataSource.

In the child grid I have a ASP Button in a template column.

How do I wire the button to that when it is clicked it does a partial postback to update or rebind the child grid or itself.

I have tried it like this but no luck.

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    if (e.Item is GridDataItem) 
    { 
        GridDataItem dataItem = e.Item as GridDataItem; 
        Button Button1 = (Button)(dataItem["TemplateColumn"]).FindControl("Button1"); 
        Button1.OnClientClick = String.Format(@"{0}.__doPostBack(""{1}"",""{2}"");return false;", RadAjaxManagerProxy1.ClientID, Button1.UniqueID, Button1.CommandArgument); 
     
    } 

Or using this:

GridTableView tableView = e.Item.OwnerTableView; 
GridTableView detailView = tableView.Items[e.Item.ItemIndex].ChildItem.NestedTableViews[1]; 






Thanks

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 15 Sep 2008, 02:55 PM
Hi Howard,

You can use the following code in order to check if the created item is of the MasterTableView or the detail table:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)    
{    
    if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "DetailTableName")    
    {   
        //place your implementation here  
    }  

However, I suggest that you ajaxify the whole grid instead of adding ajaxsettings for each button in the detail table.

Find more about RadGrid hierarchy in the following articles:
http://www.telerik.com/help/aspnet-ajax/grdunderstandinghierarchy.html
http://www.telerik.com/help/aspnet-ajax/grdtraversingdetailtablesitemsingrid.html

Let us know if this helps.

All the best,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Officialboss
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or