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

[Solved] Find control on Parent Row When Expanding

4 Answers 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 30 Oct 2009, 04:03 PM
I am trying to find a control on the parent row when expanding the grid during the ItemCommand Event.  I am unable to do so.  Can someone post a small example please?



Thanks

--Randy

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Nov 2009, 08:24 AM
Hi,

Try the code snippet below to access the control in the parent item on clciking a button  in the detail table

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "CustomCommand"
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            GridDataItem parentItem = (GridDataItem)dataItem.OwnerTableView.ParentItem; 
        }  
    }

Thanks,
Shinu
0
Randy
Top achievements
Rank 1
answered on 02 Nov 2009, 07:00 PM
With the above while expaning I get the ParentItem is nothing

Here is my Code:

 

Protected Sub rgPrismQA_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgPrismQA.ItemCommand

 

 

Dim mecb As MutuallyExclusiveCheckBoxExtender = Nothing

 

 

 

Select Case e.CommandName

 

 

Case RadGrid.ExpandCollapseCommandName

 

 

Dim di As GridDataItem = e.Item

 

 

Dim pi As GridDataItem = di.OwnerTableView.ParentItem

 

 

 

 

 

End Select

 

 

End Sub

So here When expanding pi is nothing and I can't find the control.  Any Ideas?

 

0
Randy
Top achievements
Rank 1
answered on 03 Nov 2009, 06:52 PM
Does anyone have any ideas on this?
0
Shinu
Top achievements
Rank 2
answered on 04 Nov 2009, 05:22 AM
Hi Randy,

I guess you want to access the control placed in the griditem which is expanded/collapsed. If so you can try the following code snippet.

VB:
 
Protected Sub RadGrid1_ItemCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridCommandEventArgs) 
    Select Case e.CommandName 
        Case RadGrid.ExpandCollapseCommandName 
            Dim di As GridDataItem = DirectCast(e.Item, GridDataItem) 
            Dim textbox1 As TextBox = DirectCast(di.FindControl("TextBox1"), TextBox)      
            ' Where TextBox1 is placed in the templatecolumn of expanded/collapsed item 
            Exit Select         
    End Select 
End Sub 

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