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

Can not find CommandItem in DetailTableView?

1 Answer 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Elton
Top achievements
Rank 1
Elton asked on 15 Oct 2008, 05:42 AM
Hello,

I am trying to use commandItem in detailtable in a hierachy grid.
My detail table is in 3rd level and I use code like:

GridCommandItem commandItem = (GridCommandItem)grid.MasterTableView..DetailTables[0].DetailTables[0].GetItems(GridItemType.CommandItem)[0];

I always get "Out of boundry of Index" exception.

Is there any attribute I should turn on or sth. I did wrong ?
Any idea on this issue

Regards,
Elton

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Oct 2008, 05:56 AM
Hi Elton,

Set the Name property for the detail table and try accessing the CommandItem for the Detail table in the ItemDataBound event as shown below.


ASPX:
 <DetailTables> 
                   <telerik:GridTableView runat="server" CommandItemDisplay="Top" Name="Detail2" DataSourceID="SqlDataSource1" > 
                   

CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridCommandItem)&&(e.Item.OwnerTableView.Name == "Detail2")) 
        { 
            GridCommandItem cmditm = (GridCommandItem)e.Item; 
            LinkButton insertbtn = (LinkButton)cmditm.FindControl("InitInsertButton"); 
 
        } 
 
    } 


Thanks
Shinu.
Tags
Grid
Asked by
Elton
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or