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

[Solved] How to find the parent row of a nested grid's row on events

1 Answer 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 2
Alex asked on 16 Jun 2009, 04:58 PM

OK you may be confused by the title of the post, but I didn't really know how to express a good title for the post.

Here's what I have, I've got a nested grid in a grid and on events such as item_databound of the nested grid I need to find the parent row of the nested grid.

I've found a convoluted way in finding it, but I'm sure there's a simpler way, here's how I do it on the item_databound:

DirectCast(e.Item.Parent.Parent.Parent.Parent.Parent.Parent, Telerik.Web.UI.GridNestedViewItem).ParentItem

I have a similar convoluted way in getting this in a rowdrop event from the nested grid's

DirectCast(e.DragedItems(0).Parent.Parent.Parent.Parent.Parent.Parent, Telerik.Web.UI.GridNestedViewItem).ParentItem

Here's a quick example of what I'm doing:

Public Sub rdgInvoices_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) 'Handles rdgInvoices.ItemDataBound  
        Static Total As Double  
 
        If TypeOf e.Item Is Telerik.Web.UI.GridDataItem Then  
(e.Item.Parent, "TelerikForAjax")  
 
            Dim gdiParent As Telerik.Web.UI.GridDataItem = DirectCast(e.Item.Parent.Parent.Parent.Parent.Parent.Parent, Telerik.Web.UI.GridNestedViewItem).ParentItem  
 
            If DirectCast(gdiParent.FindControl("lblDirectExpense"), Label).Text = "1" OrElse DirectCast(e.Item.FindControl("lblDirectExpense"), Label).Text = "1" Then  
                With e.Item  
                    DirectCast(.FindControl("lblInvoice"), Label).Visible = False 
                    With DirectCast(.FindControl("txtInvoice"), TextBox)  
                        .Visible = True 
                        ' ''On Error Resume Next  
                        ' ''.Attributes.Remove("updateDE")  
                        ' ''On Error GoTo 0  
                        ' ''.Attributes.Add("onChange", "updateDE('" & directcast(e.Item.FindControl("txtInvoice"), Label).ClientID & "', '" & & "')")  
                    End With  
                    Dim rdg As Telerik.Web.UI.GridDataItem = ParentRow(e.Item.Parent, "TelerikForAjax")  
 
                    With DirectCast(.FindControl("txtAmount"), TextBox)  
                        .Attributes.Add("onChange", "updateDE('" & DirectCast(e.Item.FindControl("lblAmount"), Label).ClientID & "','" & DirectCast(.FindControl("txtAmount"), TextBox).ClientID & "', '" & DirectCast(rdgCategoryBudget.Items(CurrentCategoryRow).FindControl("txtReconciled"), TextBox).ClientID & "', '" & DirectCast(rdg.FindControl("txtReconciled"), TextBox).ClientID & "', '" & DirectCast(rdgCategoryBudget.Items(CurrentCategoryRow).FindControl("lblSavings"), Label).ClientID & "', '" & DirectCast(rdgCategoryBudget.Items(CurrentCategoryRow).FindControl("lblTotal"), Label).ClientID & "')")  
                        .ReadOnly = Not AllowReconciliation  
                    End With  
 
                End With  
      End If  
 
End Sub 

1 Answer, 1 is accepted

Sort by
0
Alex
Top achievements
Rank 2
answered on 16 Jun 2009, 07:04 PM
Please ignore I found a forums posting that explains a way better and easier way to find it.
Tags
Grid
Asked by
Alex
Top achievements
Rank 2
Answers by
Alex
Top achievements
Rank 2
Share this question
or